/// <summary> /// It serializes dictionary in binary format and stores it in a binary file. /// </summary> public void Save() { //BRIDGETODO : implemente the code below #if !BRIDGE // IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null); IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); Stream stream = new IsolatedStorageFileStream(Filename, FileMode.Create, isoStore); try { // Serialize dictionary into the IsolatedStorage. Formatter.Serialize(stream, AppDictionary); } finally { stream.Close(); } #endif }
public void OpenFile_PassesFileAccess() { TestHelper.WipeStores(); using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { string file = "OpenFile_PassesFileAccess"; using (var stream = isf.OpenFile(file, FileMode.CreateNew, FileAccess.Write)) { Assert.True(isf.FileExists(file), "file exists"); stream.WriteByte(0xAB); } using (var stream = isf.OpenFile(file, FileMode.Open, FileAccess.Read)) { Assert.Equal(0xAB, stream.ReadByte()); Assert.Throws <NotSupportedException>(() => stream.WriteByte(0xCD)); } } }
public void OpenFile_PassesFileShare() { TestHelper.WipeStores(); using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { string file = "OpenFile_PassesFileShare"; using (var stream = isf.OpenFile(file, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite)) { Assert.True(isf.FileExists(file), "file exists"); using (isf.OpenFile(file, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { } } using (var stream = isf.OpenFile(file, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { Assert.True(isf.FileExists(file), "file exists"); Assert.Throws <IsolatedStorageException>(() => isf.OpenFile(file, FileMode.Open, FileAccess.ReadWrite)); } } }
public static IsolatedStorageFile GetIsolatedStorageFile() { return(IsolatedStorageFile.GetUserStoreForAssembly()); }