Programmatically flush Silverlight application store?

I have a Silverlight application for some clients. I am having problems releasing updates.

I would like the user to load the web page initially, if their application store is older than the last time the site was updated, then this happens. This will make my application work.

So, two questions:

  • How do I check if users stored in the application store have the latest update for the Silverlight site?

  • How to remove the application store for the site?

I tried to call:

using( var store = IsolatedStorageFile.GetUserStoreForApplication() ) { store.Remove(); } using( var store = IsolatedStorageFile.GetUserStoreForSite()) { store.Remove(); } 

in the App.xaml.cs file, but they do not seem to affect the page displayed - the application store is not completely empty.

+4
source share
2 answers

• How can I check if users are storing an application store older than the last update on the Silverlight site?

this code is included in the application to check if there is and update your SL application. I don't know if it helps, but if you just want to do something with this IsolStorageFile, when the update should be what you want:

 Application.Current.CheckAndDownloadUpdateAsync(); Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted); private void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e) { if (e.UpdateAvailable) { } } 

• How to remove the application store for the site?

 IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); if(store.FileExists(FileName)) { store.DeleteFile(FileName); } 
+4
source

You can write the creation date of your xap file to the initParams of the Silverlight object.

 <object id="xaml" data="data:application/x-silverlight-2," type="application/x-silverlight-2"> <param name="initParams" value="<%= GetInitParams() %>" /> 

In the code behind the file, you write something like this:

 protected string GetInitParams() { string xappath = HttpContext.Current.Server.MapPath(@"~/ClientBin/YourXapFile.xap"); DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath); return string.Format("lastUpdateDate={0:d}, xapCreationDate); } 

In the Silverlight client, you can compare this date with the latest application store update. You can find the date and time of the last update using the GetLastWriteTime() method of the IsolatedStorageFile object.

Then you compare these two dates and delete the file with Deletefile , if necessary.

0
source

Source: https://habr.com/ru/post/1434168/


All Articles