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?
Among the vast number of classes and functions provided by the Microsoft .NET Framework, exists a new and powerful feature for storing information relating to users and applications called Isolated Storage. The System.IO.IsolatedStorage namespace allows data to be written to the hard disk where sometimes this is not allowed.
The IsolatedStorageFile class provides most of the necessary functionality for isolated storage. Use this class to obtain, delete and manage isolated storage. The IsolatedStorageFileStream class handles reading and writing files to a store. This is similar to reading and writing in standard File I/O classes.
The IsolatedStorageScope enumeration indicates different types of isolation. For more information about when to use isolated storage, see Isolated Storage. Represents the abstract base class from which all isolated storage implementations must derive. The exception that is thrown when an operation in isolated storage fails.
The IsolatedStorageFileStream class handles reading and writing files to a store. This is similar to reading and writing in standard File I/O classes. For more information about I/O, see the System.IO namespace.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With