by Corrado Cavalli via Corrado's BLogs on 10/15/2010 6:41:08 AM
Today I lost some time trying to figure out why my Windows Phone 7 application settings got lost as soon as the application was restarted. After several tests have concluded that the offending code was following one, which, at startup, deletes some “*.cache” files used by the application to store some temporary information.
private void ClearCache(){ string[] cacheFiles = this.store.GetFileNames("*.cache"); foreach (string cacheFile in cacheFiles) { this.Delete(cacheFile); }}
Everything looks ok, except that the application settings are stored in a file called “__ApplicationSettings.cache” and so they were automatically deleted at startup (funny isn’t it?)
Changing the code to the following does fixes it:
private void ClearCache(){ IEnumerable<string> cacheFiles = this.store.GetFileNames("*.cache") .Where(file => file != "__ApplicationSettings") .Select(file => file); foreach (string cacheFile in cacheFiles) { this.Delete(cacheFile); }}
Next time I create temporary files I will take good care to not use a meaningful extension… Haven’t tried but I presume the same applies to any Silverlight application.
Original Post: Beware of .cache files on IsolatedStorage
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.