Monday, March 12, 2012

Delete Contents of IsolatedStorageFile

The easiest way to delete contents of an IsolatedStorageFile is to open it in the Truncate mode:

IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();

IsolatedStorageFileStream isoFile = new IsolatedStorageFileStream(myFileName, FileMode.Truncate, isoStore);

According to the MSDN , if a file is opened in the Truncate mode its size should be 0 bytes.