Description: In this Article I will describe using Isolations Storage; how to fetch and display video and image files using Isolation Storage in Silverlight.Content: Silverlight uses Isolated Storage as a virtual file system to store data in a hidden folder on your machine. It breaks up the data into two separate sections: Section 1 contains administrative information such as disk quota and section 2 contains the actual data. Each Silverlight application is allocated its own portion of the storage with the current quota set to be 1 MB per application. It is the by default storage quota. So if the quota exceeds that then you have to programmatically increase the Isolation Storage Quota. That I will describe in this article Later. Reference - http://www.telerik.com/help/silverlight/consuming-data-isolated-storage.html First create a new Silverlight Application with the name Isolation Media Element.Now create a UserControl Name DisplayVideo.xaml. Which I will integrate to the Mainpage.xaml.In the main Page.xaml I have written the code for fetching and display the image file from Isolation Storage.In the DisplayVideo.xaml I have written the code for fetching and playing the video file from Isolation Storage.Here when you will click the "Save file in IS" button a filedialog will open. You choose the image and it will store it into IsolationStorage. When you click the "Read file in IS" button it will fetch from the Isolation Location and will play it.In this e.g. only .wmv video file will play.When you click the button "Increase Quota" it will automatically increase the Isolation quota by 1gb.For doing this operation I have created a separate class name SaveIsolation.cs. Where I have mentioned all thenecessary methods for fetching and displaying a file from isolation storage.Now In the MainPage.xaml I have added the DisplayVIdeo.xaml UserControl. In the figure below I marked it as Black. The Content of the Display Video will automatically come in.Place <local:DisplayVideo x:Name="ucvideo"></local:DisplayVideo>Code under the grid section.Now To increase the IsolationStorage the method is://this method is for increase the isolation storaze size public bool Stor_IncreaseQuota(long bt) { try { using (IsolatedStorageFile oStore = IsolatedStorageFile.GetUserStoreForApplication()) { // 5MB long iQuotaCur = oStore.Quota; ulong iQuotaCur1 = (ulong)oStore.Quota; long iQuotaAvl = oStore.AvailableFreeSpace; long gb = 1024 * 1024 * 1024; long iQuotaNew = (gb + iQuotaAvl + bt); ulong iQuotaNew1 = (ulong)iQuotaNew;
if (iQuotaNew1 > iQuotaCur1) { if (oStore.IncreaseQuotaTo(iQuotaNew) == true) { // The user clicked Yes to the // host's prompt to approve the quota increase. return true; } else { // The user clicked No to the // host's prompt to approve the quota increase. return false; } } else { return false; } } } catch (IsolatedStorageException) {
return false; } }And finally to set the Application to the Out of browser application go to OutOfBrowserSettings.xml.Under properties add this code:<OutOfBrowserSettings ShortName="IsolationMediaElement Application" EnableGPUAcceleration="False" ShowInstallMenuItem="True"> <OutOfBrowserSettings.Blurb>IsolationMediaElement Application on your desktop; at home, at work or on the go.</OutOfBrowserSettings.Blurb> <OutOfBrowserSettings.WindowSettings> <WindowSettings Title="IsolationMediaElement Application" /> </OutOfBrowserSettings.WindowSettings> <OutOfBrowserSettings.Icons /></OutOfBrowserSettings>Like as in the picture below.I have attached the Source Code here.The Isolation path for Windows XP is...C:\Documents and Settings\shirsendun\Local Settings\Application Data\Microsoft\SilverlightRun the Code. I have chosen an image file and when the read button is clicked it looks like.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: