Using isolated storage for application-specific data in C# .NET Part 3: storage location

In this post we looked briefly at how to work with directories in isolated storage. In this post we’ll look at where isolated storage files are saved on disk depending on the isolation type: by user or by machine.

Recall our code to save the program settings specifically for the user:

private static void SaveSettingsInIsoStorage()
	IsolatedStorageFile applicationStorageFileForUser = IsolatedStorageFile.GetUserStoreForAssembly();
	long quotaInBytes = applicationStorageFileForUser.Quota;
	string[] directoryNames = applicationStorageFileForUser.GetDirectoryNames("AppSettings");
	if (!directoryNames.Any())
	IsolatedStorageFileStream applicationStorageStreamForUser = new IsolatedStorageFileStream("AppSettings/settings.txt", FileMode.Create, applicationStorageFileForUser);
	AppSettings settings = new AppSettings()
		Job = "Programmer",
		Language = "C#",
		Name = "Andras"
	string contents = JsonConvert.SerializeObject(settings);

	using (StreamWriter sw = new StreamWriter(applicationStorageStreamForUser))

There’s no property that lets you easily read the actual location on disk. You’ll need to set a breakpoint right after this line:

private static void SaveSettingsInIsoStorage()
	IsolatedStorageFile applicationStorageFileForUser = IsolatedStorageFile.GetUserStoreForAssembly();

When the code execution stops hover over “applicationStorageFileForUser” and open the “Non-public members” section. You’ll see a property called RootDirectory in the bottom of the list. The value should point to a user-specific location. In my case it is…


…and there it is:

Isolated storage file location for user

Let’s change the code so that we save the settings at the machine level:

private static void SaveSettingsInIsoStorage()
       IsolatedStorageFile assemblyStorageFileForMachine = IsolatedStorageFile.GetMachineStoreForAssembly();

The same hidden RootDirectory property will point to the ProgramData folder similar to the following:


Let’s check:

Isolated storage file location for machine

Read the finishing part here.

Read all posts dedicated to file I/O here.


About Andras Nemes
I'm a .NET/Java developer living and working in Stockholm, Sweden.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


A great site

Elliot Balynn's Blog

A directory of wonderful thoughts

Robin Sedlaczek's Blog

Developer on Microsoft Technologies

HarsH ReaLiTy

My goal with this blog is to offend everyone in the world at least once with my words… so no one has a reason to have a heightened sense of themselves. We are all ignorant, we are all found wanting, we are all bad people sometimes.

Softwarearchitektur in der Praxis

Wissenswertes zu Webentwicklung, Domain-Driven Design und Microservices

the software architecture

thoughts, ideas, diagrams,enterprise code, design pattern , solution designs

Technology Talks

on Microsoft technologies, Web, Android and others

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

Anything around ASP.NET MVC,WEB API, WCF, Entity Framework & AngularJS

Cyber Matters

Bite-size insight on Cyber Security for the not too technical.

Guru N Guns's

OneSolution To dOTnET.

Johnny Zraiby

Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

%d bloggers like this: