Various folders available from VB.NET code

Administrator

VB.NET Forum Admin
Joined
Jun 3, 2004
Messages
1,462
Programming Experience
10+
I ran a test to see what the different folders that code would provide via different code methods. I recall a recent discussion along this product related to Vista and how some folders may be different between XP and Vista, for example. However, I'm also curious which of these folders are "safe" for use with Vista's User Account Control (UAC) system. Share any comments regarding folders for use with our VB.NET apps. I'm changing some names in the paths below to protect the name of a new application in development.

"neal007" is the logged on user
2.0.0.0 is the FILE (not Assembly) version

VB.NET:
[COLOR=#008000][FONT=Courier New]'<FOLDERS>[/FONT][/COLOR]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Application.LocalUserAppDataPath"[/COLOR], Application.LocalUserAppDataPath))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Application.CommonAppDataPath"[/COLOR], Application.CommonAppDataPath))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Application.ExecutablePath"[/COLOR], Application.ExecutablePath))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Application.UserAppDataPath"[/COLOR], Application.UserAppDataPath))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Environment.SpecialFolder.ApplicationData"[/COLOR], System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Environment.SpecialFolder.CommonApplicationData"[/COLOR], System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Environment.SpecialFolder.LocalApplicationData"[/COLOR], Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Environment.SpecialFolder.MyDocuments"[/COLOR], Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"Environment.SpecialFolder.Personal"[/COLOR], System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)))[/FONT]
[FONT=Courier New]Console.WriteLine([COLOR=#0000ff]String[/COLOR].Format([COLOR=#a31515]"{0}: {1}"[/COLOR], [COLOR=#a31515]"My.Application.Info.DirectoryPath"[/COLOR], [COLOR=#0000ff]My[/COLOR].Application.Info.DirectoryPath))[/FONT]
 
[COLOR=#008000][FONT=Courier New]'/// Results from above ///[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Application.LocalUserAppDataPath: C:\Users\neal007\AppData\Local\NC Software\MyAppName\2.0.0.0 [/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Application.CommonAppDataPath: C:\ProgramData\NC Software\MyAppName\2.0.0.0[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Application.ExecutablePath: E:\DotNet 2005\MyAppName\MyAppFolder\bin\Debug\MyApp.EXE[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Application.UserAppDataPath: C:\Users\neal007\AppData\Roaming\NC Software\MyAppName\2.0.0.0[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Environment.SpecialFolder.ApplicationData: C:\Users\neal007\AppData\Roaming[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Environment.SpecialFolder.CommonApplicationData: C:\ProgramData[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Environment.SpecialFolder.LocalApplicationData: C:\Users\neal007\AppData\Local[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Environment.SpecialFolder.MyDocuments: C:\Users\neal007\Documents[/FONT][/COLOR]
[COLOR=#008000][FONT=Courier New]'Environment.SpecialFolder.Personal: C:\Users\neal007\Documents[/FONT][/COLOR]
[SIZE=3][COLOR=#008000][FONT=Courier New][SIZE=2]'My.Application.Info.DirectoryPath: E:\DotNet 2005\MyAppName\MyAppFolder\bin\Debug[/SIZE][/FONT][/COLOR]
[/SIZE]
 
Back
Top