Reputation: 6050
I have a Silverlight app published for some customers. I am having problems issuing updates.
I would like for when a user loads the webpage initially, if their Application Storage is older than the last time the site was updated, then this happens. This will make my application work.
So, two questions:
How can I check if the users stored Application Storage is older than the last update to the Silverlight site?
How can I delete the Application Storage for the site ?
I have tried calling:
using( var store = IsolatedStorageFile.GetUserStoreForApplication() ) {
store.Remove();
}
using( var store = IsolatedStorageFile.GetUserStoreForSite()) {
store.Remove();
}
in the App.xaml.cs
file, but these seem to have no effect on the displayed page - the Application Storage is not fully cleared.
Upvotes: 4
Views: 1686
Reputation: 9129
You could write the file creation date of your xap file into 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 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);
}
Within the Silverlight client you can compare this date with the last update of the application storage. You can find the date and time of the last update with the method GetLastWriteTime()
on the IsolatedStorageFile
object.
Then you compare these two dates and delete the file with Deletefile
if needed.
Upvotes: 0
Reputation: 448
•How can I check if the users stored Application Storage is older than the last update to the Silverlight site?
this code go in app to check if there's and update to your SL application I don't know if it help but if you just want to do something with that IsolatedStorageFile when there's update it 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 can I delete the Application Storage for the site ?
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
if(store.FileExists(FileName))
{
store.DeleteFile(FileName);
}
Upvotes: 4