Apoorv Apoorv - 7 months ago 42
Vb.net Question

Programatically get the folder location

I have this VB code which on debugging gets me the following location

C:\Users\AUpadhyay\AppData\Roaming\Sterling Ultra Precision\Power

The VB Code is

AppPath = System.IO.Directory.GetParent(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData).ToString

I was trying to reach the same directory using the below C# code but the output is


The C# code is

AppPath = System.IO.Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).ToString();

What would be the line of code to get the same directory address ?


Application.UserAppDataPath would be your solution.

It's accessible from both VB.NET and C#, and it returns:

C:\Users\[Your user name]\AppData\Roaming\[Your company name]\[Your product name]\[Your product version]

Result from C#:

Application.UserAppDataPath in a MessageBox