How to get Windows\system32\config\systemprofile\AppData\Local\ folder path in C#?

9.4k Views Asked by At

What is the best way to get this folder path programmatically : Windows\system32\config\systemprofile\AppData\Local ?

4

There are 4 best solutions below

5
On

I can't write comments sorry. What are you using the path for? Where is the application stored? This will get you there??

string path = "C:\\Windows\system32\config\systemprofile\AppData\Local";

Provided C: is the name of the drive.

You really need to expand on your question a little bit.

Is this a duplicate question??

How to read existing text files without defining path

12
On

I think you can use Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData

In my project like this string configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MyProject", "SERVICER", "config.ini");

It get Application Data Directory for all user ( contain System, Service, Guest,... ). I use it for save config of Service!!

1
On

You can get the path this way:

Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData)
0
On

Sample code

HttpContext.Current.Server.MapPath();
System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;