469,281 Members | 2,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

Obtaining the Application Data Folder correctly

Our application needs to write some application specific data, but I have
not been able to find the recommended method to obtain the correct pathname.

I have found many references to the SHGetFolderPath function, but have not
been able to find any way to access this in VB.Net. Apologies in advance if I
have missed something obvious...

I have implemented this in the following function, using the Registry Key
HKEY_CURRENT_USER\Volatile Environment\APPDATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationDataFolder() As String
Dim AppDataRegKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser.CreateSubKey( "Volatile Environment")
If AppDataRegKey.GetValue("APPDATA") Is Nothing Then
MessageBox.Show("Error: Application Data Path not found",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Else
Return CType(AppDataRegKey.GetValue("APPDATA"), String)
End If
End Function
Thanks for any assistance,
Tim Failes
Advanced User Systems
Jul 21 '05 #1
2 29578
Tim,

You could get a path to user's specific application data folder using:

Environment.GetFolderPath(SpecialFolder.Applicatio nData)

and create a folder there for your application's data.

HTH,

Alexander Shirshov
"Tim Failes" <Ti*******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
Our application needs to write some application specific data, but I have
not been able to find the recommended method to obtain the correct
pathname.

I have found many references to the SHGetFolderPath function, but have not
been able to find any way to access this in VB.Net. Apologies in advance
if I
have missed something obvious...

I have implemented this in the following function, using the Registry Key
HKEY_CURRENT_USER\Volatile Environment\APPDATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationDataFolder() As String
Dim AppDataRegKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser.CreateSubKey( "Volatile Environment")
If AppDataRegKey.GetValue("APPDATA") Is Nothing Then
MessageBox.Show("Error: Application Data Path not found",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Else
Return CType(AppDataRegKey.GetValue("APPDATA"), String)
End If
End Function
Thanks for any assistance,
Tim Failes
Advanced User Systems

Jul 21 '05 #2
Thank you! I thought there was a better way than what I was doing!
Tim

"Alexander Shirshov" wrote:
Tim,

You could get a path to user's specific application data folder using:

Environment.GetFolderPath(SpecialFolder.Applicatio nData)

and create a folder there for your application's data.

HTH,

Alexander Shirshov
"Tim Failes" <Ti*******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
Our application needs to write some application specific data, but I have
not been able to find the recommended method to obtain the correct
pathname.

I have found many references to the SHGetFolderPath function, but have not
been able to find any way to access this in VB.Net. Apologies in advance
if I
have missed something obvious...

I have implemented this in the following function, using the Registry Key
HKEY_CURRENT_USER\Volatile Environment\APPDATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationDataFolder() As String
Dim AppDataRegKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser.CreateSubKey( "Volatile Environment")
If AppDataRegKey.GetValue("APPDATA") Is Nothing Then
MessageBox.Show("Error: Application Data Path not found",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Else
Return CType(AppDataRegKey.GetValue("APPDATA"), String)
End If
End Function
Thanks for any assistance,
Tim Failes
Advanced User Systems


Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Dennis C. Drumm | last post: by
1 post views Thread by Bry | last post: by
4 posts views Thread by Bob | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.