C# – How to get the AppData VirtualStore path of an application

cnetwindows 7

I want to get application's path in VirtualStore.

For example, the file which I need is in this directory (I'm getting this path from registry)

C:\Program Files (x86)\Example App\data.ini

How can I get this path?

C:\Users\User388\AppData\Local\VirtualStore\Program Files (x86)\Example App\data.ini

UPDATE:

This paths in not my application.

I asked how it possible to get path in app data when only know winodows username and path in program files

Best Answer

Assuming that Example App is the application running the code the first directory is retrieved using

string strFilePath = Path.Combine(Application.ExecutablePath, "Data.ini");

The second doesn't at first glance look like a set location, but for this you can experiment with the Application and Environment classes. Try something like

string strFilePath = Path.Combine(Application.UserAppDataPath, "Data.ini");

I hope this helps.

Edit: See this link https://stackoverflow.com/a/3916868/626442 for your answer.