SIGN UP MEMBER LOGIN:    
ARTICLE

How to Read and Write Large Video Files in Silverlight OOB Application

Posted by Jaganathan Bantheswaran Articles | Silverlight with C# February 20, 2011
In this article, we will see how to read and write large video files in a Silverlight OOB Application. The interesting thing here is that one of my questions in the c-sharcorner site’s forum became this article.
Reader Level:
 


Introduction:

In this article, we will see how to read and write large video files in a Silverlight OOB Application. The interesting thing here is that one of my questions in the c-sharcorner site's forum became this article.

Creating Silverlight OOB Application:

As your VS 2010 is taking a rest in the Windows taskbar, just minimize the browser window and maximize the VS 2010. So you are ready to create Silverlight OOB application now. Just follow the screenshot below [No: #].

SilOObApp1.gif

Just press OK to Create the Silverlight OOB application.

Setting for OOB Silverlight Application:

Use the settings for an OOB application as given here.

SilOObApp2.gif

Go to the Project Properties. From properties page, follow the screenshot [W1, W2 Arrows].

In Window 2, it is necessary to enable the Require elevated trust when running outside the browser checkbox.

Designing the Silverlight OOB Application:

Design the Application as per the image given below.

SilOObApp3.gif

Otherwise use the Xaml code to produce the design above.

<Grid x:Name="LayoutRoot" Background="White" Height="240" Width="600">
        <StackPanel Orientation="Vertical">
           <StackPanel Orientation="Vertical">
                <Border CornerRadius="10" Background="Black" Margin="0,20,0,0" Height="auto" Width="600">
                    <TextBlock  Margin="10"  Name="textfileName" Foreground="FloralWhite" Width="auto" TextWrapping="Wrap" />
                </Border>
                <Border Height="113" Width="400" Margin="0,20,0,0" Background="Black" CornerRadius="20">
                    <TextBlock Margin="15"  Name="textFileInfo" Foreground="FloralWhite" />
                </Border>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="10">
                <Button Content="Read" Height="22" Margin="200,0,0,0"   Name="btnRead" Width="75" Click="ReadFile" />
                <Button Content="Write" Height="23" Margin="30,0,0,0"  Name="btnWrite"  Width="75" Click="WriteFile" />
            </StackPanel>
        </StackPanel>
    </Grid>

Reading & Writing Large files:

The screenshot below shows the common way to read and write the files.

SilOObApp4.gif

What is WRONG in this code?

You may ask what is wrong in this code. There is nothing wrong if the File SIZE is smaller. However, if the file SIZE is too big then this type of error will occur.

For me up to 1289749531 bytes there is no OUT OF MEMORY error. However, when the byte size is increased by 1 then it throws an error like the one above.

How to Read Large Files?

For this, I found a solution by which you can read and write large video files above 1.5 GB.

SilOObApp5.gif

In th preceding code there is no buffer used at all. The Method CopyTo() is used here to write the large video files.

Application in Action:

SilOObApp6.gif

Summary:

In this article we had a look at CopyTo() method which is used to write the large video files.

Thanks for spending your precious time here. Please provide your valuable feedbacks and comments, which motivate me to write a better article next time.
Thanks.

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor