Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the AppData VirtualStore path of an application?

Tags:

c#

.net

windows-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

like image 918
user525717 Avatar asked Jul 04 '12 16:07

user525717


1 Answers

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.

like image 96
MoonKnight Avatar answered Oct 12 '22 23:10

MoonKnight