static void DeleteFileFromIsolatedStorage(string fileName) { string original = fileName; if (!fileName.Contains(IsolatedStoragePrefix)) { throw new ArgumentException("You must use isolated storage. Use FileManager.GetUserFolder."); } fileName = FileManager.GetIsolatedStorageFileName(fileName); #if WINDOWS_8 || UWP // Why did we do the original name? We're in iso storage so we should use the modified name: //var storageFile = ApplicationData.Current.LocalFolder.GetFileAsync(original).Await(); var storageFile = ApplicationData.Current.LocalFolder.GetFileAsync(fileName).Await(); storageFile.DeleteAsync().Await(); #else IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); storage.DeleteFile(fileName); //IsolatedStorageFileStream isfs = null; //isfs = new IsolatedStorageFileStream( // fileName, FileMode.Create, mIsolatedStorageFile); //writer = new StreamWriter(isfs); #endif }
static void SaveGarbageIsolatedStorage(byte[] garbageBytes, string fileName) { if (!fileName.Contains(IsolatedStoragePrefix)) { throw new ArgumentException("You must use isolated storage. Use FileManager.GetUserFolder."); } #if WINDOWS_8 || UWP throw new NotImplementedException(); #else BinaryWriter writer = null; fileName = FileManager.GetIsolatedStorageFileName(fileName); IsolatedStorageFileStream isfs = null; using (isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, mIsolatedStorageFile)) using (writer = new BinaryWriter(isfs)) { writer.Write(garbageBytes); Close(writer); } #endif }