0

After using the free version of InstallShield and installing my app on my machine I noticed that my data file (a sqlite .db file) is being saved in a different location than when I run it under Visual Studio. Basically instead of being saved in the directory with the .exe file it is being saved here: C:\Users\blaaah\AppData\Local\VirtualStore\Program Files (x86)\MyAppA\MyAppA

My .exe file with its .dll files is being saved here: C:\Program Files (x86)\MyAppA\MyAppA

I am curious as to why that is happening? I am also curious on how to get that directory that contains my data file with code.

1
  • Because InstallShield is smart. Google for AppData (to example, here is something). Commented Jan 29, 2015 at 15:19

1 Answer 1

1

The VirtualStore folder is caused by file system redirection done by UAC. By doing this, Microsoft was able to lock down the Program Files directory without sacrificing too much backward compatibility. Any time an application tries to write to the program files location, the write will be redirected to the Virtual Store.

A decent writeup on this on MSDN can be found in the User Account Control For Game Developers article.

To quote that article:

Virtualization affects the file system and registry by redirecting system-sensitive writes (and subsequent file or registry operations) to a per-user location within the current user's profile. For example, if an application attempts to write to the following file:

C:\Program Files\Company Name\Title\config.ini

the write is automatically redirected to:

C:\Users\user name\AppData\Local\VirtualStore\Program Files\Company Name\Title\config.ini

Likewise, if an application attempts to write a registry value like the following:

HKEY_LOCAL_MACHINE\Software\Company Name\Title

it will be redirected instead to:

HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\Software\Company Name\Title

Sign up to request clarification or add additional context in comments.

5 Comments

So I need to look into the registry to find the actual directory my data file is located at? There isn't some kind of command like: Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); that I could use to find it?
No, you should not write files to C:\Program Files\ , rather store your data in System.Environment.SpecialFolder.ApplicationData or System.Environment.SpecialFolder.CommonApplicationData
No what I am asking is how to get the Path of the data file when it is being placed here by the OS: C:\Users\blaaah\AppData\Local\VirtualStore\Program Files (x86)\MyAppA\MyAppA How can I use some C# code to figure out the actual physical location of the file.
Please read this answer: stackoverflow.com/questions/20570754/…. In short, don't rely on the redirection and save files to the appropriate locations.
Yeah I think you are right. Saving them to to a appropriate location will prevent alot of pain and grief. Thanks for your aid.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.