C# – How to know VirtualStore is applied in the application

c

I am developing an application which will run on Windows OS. However, when run it on Windows Vista, my application's settings is stored in VirtualStore. How to check VirtualStore is being applied in my application (I need a function to check and it must ok on XP, Vista).

And how to get the path of Virtual Store of my application.

Thanks.

Best Answer

My workaround...

You get the user Appdata path:

String appdata = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

Add VirtualStore folder to path:

String VirtualStoreRoot = appdata + "\\VirtualStore";

Create folder:

String backuppath = "C:\\Program Files\\Progname\\backup";
Directory.CreateDirectory(backuppath);

Check created in VirtualStore

String newpath = VirtualStoreRoot + backuppath.Substring(2);
if (Directory.Exists(newpath)){
   backuppath = newpath;
}

I found another stuff:

Isolated Storage with .NET