Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IsolatedStorage Not Working With IE Protected Mode? C#

Using IsolatedStorage with IE Protected Mode.

I am building a C# .NET (VS2010) IE8 add-on application but am having some trouble saving data using IsolatedStorage on a Windows 7 64-bit machine, when Internet Explorer's default Protected Mode is enabled.

(I am switching to this method from using Settings as Properties.Settings.Default.Save(); which also failed with IE Protected Mode on. I also tried saving files in LocalLow with no luck either.)

Could anyone point out how I can amend the following code please to enable it to work with IE Protected Mode? I have tried so many ideas and nothing so far has worked. Surely there must be a way to save data??

//FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted); 
    //perm.Assert(); 
    //perm.Demand();  

//---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();
like image 256
Donna Avatar asked Dec 14 '25 14:12

Donna


1 Answers

You aren't providing any the evidence arguments.

Have you tried the following overloads instead of GetStore:

  • GetUserStoreForApplication
  • GetUserStoreForUser
  • GetUserStoreForDomain
  • GetMachineStoreForApplication
  • GetMachineStoreForUser
  • GetMachineStoreForDomain

What operating system are you using? What version of .NET are you using? What file system type are you executing this on? Are you the administrator of the machine? What is the IsolatedStorage policy on the machine? Is it enabled? How much space does each user have?

Can you observe the app_started.txt file being created in the appropriate directory? If not then you might also have a permissions issue... NTFS ACL etc...

http://msdn.microsoft.com/en-us/library/3ak841sy(v=vs.80).aspx

Just some suggestions.

HTH

like image 187
Helper Avatar answered Dec 16 '25 06:12

Helper