Does anyone use .NET's System.IO.IsolatedStorage?
Asked Answered
I

2

13

I was reading about the System.IO.IsolatedStorage namespace in .NET and found that I can use it to store a file to a location unique for my assembly or executable. For example, the following code:

using System.IO.IsolatedStorage;

public class Program
{
     static void Main(string[] args)
     {
           IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly();
           store.CreateFile("myUserFile.txt");
     }
 }

Creates the file "myUserFile.txt" at the following location:

C:\Users\Nick\AppData\Local\IsolatedStorage\bhxcjtkp.bpv\wbjkcolm.3br\StrongName.m2s0saaun2onmow3pd5pkml30lf2dobr\AssemFiles

And using IsolatedStorageFile.GetMachineStoreForAssembly() creates a similar directory structure under C:\ProgramData\IsolatedStorage.

I can see the benefit of letting this API create a storage location for you (not having to think up a file path yourself). But I was surprised to see that there weren't any other files stored in IsolatedStorage from other third-party applications (at least not on my computer).

Instead, I found quite a few programs storing configuration files and such simply under C:\Users\Nick\AppData\Local. Does anyone know of a reason why software vendors might shy away from using IsolatedStorage? Or are they using a different API that stores files under AppData?

Inelastic answered 19/8, 2011 at 2:28 Comment(1)
I'm pretty sure many, many people are using IS.Tale
I
9

One reason that we found (the hard way) is that the algorithm that applications use to identify the path to use under isolated storage is dependent upon the application version. Installing a new version of the application results in an inability to access previously stored data. I am sure there are options to make this scenario work, but we couldn't find them and just moved to a constant storage path.

Itemize answered 19/8, 2011 at 2:46 Comment(1)
Some of the Microsoft technologies handle version upgrades automatically for you (like ClickOnce)Veii
P
4

Isolated Storage is ideal for application and user settings, and data like that. By "data like that", I mean data that isn't application-crucial (for reasons why you have seen) yet beneficial to keep away from the users' eyes.

It's very easy to clear isolated storage, so expect this to be the case always and you won't be disappointed.

Puleo answered 19/8, 2011 at 2:49 Comment(1)
Thanks. Sounds like solid advice.Inelastic

© 2022 - 2024 — McMap. All rights reserved.