C# IsolatedStorage Not Working
- by Don
I am building a C# .NET (VS2010) IE8 add-on application but am having some trouble saving data using IsolatedStorage.
No exceptions occur but, after writing the data, when I try to read the contents back it is blank, and I can find no evidence that it actually saved.
Could anyone point out any problems with the following code please that would explain why it doesn't work?
//Write
IsolatedStorageFile app_isoStore = IsolatedStorageFile.GetStore(
IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(
"app_started.txt", FileMode.OpenOrCreate, FileAccess.Write, app_isoStore);
StreamWriter iswriter = new StreamWriter(isoStream);
iswriter.WriteLine("Run");
iswriter.Close();
//app_isoStore.Dispose();
app_isoStore.Close();
//Read
IsolatedStorageFile app_isoStoreCheck = IsolatedStorageFile.GetStore(
IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
IsolatedStorageFileStream isoReadStream = new IsolatedStorageFileStream(
"app_started.txt", FileMode.Open, FileAccess.Read, app_isoStoreCheck);
StreamReader isreader = new StreamReader(isoReadStream);
string rdata = isreader.ReadToEnd();
isreader.Close();
//app_isoStoreCheck.Dispose();
app_isoStoreCheck.Close();
Should I be using:
IsolatedStorageFile.GetStore(IsolatedStorageScope.User|
IsolatedStorageScope.Domain|IsolatedStorageScope.Assembly, null,null)
instead of:
IsolatedStorageFile.GetStore(IsolatedStorageScope.User|
IsolatedStorageScope.Assembly, null, null)
What's the difference between the two GetStore examples above please?