472,344 Members | 1,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,344 software developers and data experts.

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 29717
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: tigger | last post by:
hi i have a report which i wish to reference from within the program this is what i am currently using which is fine on my local computer....
13
by: Dennis C. Drumm | last post by:
I use the Documents and Settings\All Users\Application Data\AppName folder to store xml settings that are applicable to all user who log onto a...
1
by: Bry | last post by:
My code uses System.Environment.GetFolderPath() to determine the location of the application data folder. This works fine, until I execute my...
2
by: Tim Failes | last post by:
Our application needs to write some application specific data, but I have not been able to find the recommended method to obtain the correct...
0
by: Robert | last post by:
I am developing a Windows service and am in need of storing a file in the Application Data folder. However, the Service is running on an "Local...
1
by: Fred W. | last post by:
I have an application that creates directories in ...\All Users\Application Data. When I create the directories I need to make sure all users can...
4
by: Bob | last post by:
Hi, How do you get the application folder path that a user select in a msi install which defaults to c:\Program Files\Company Name\...? Thanks,...
3
by: vijayB | last post by:
Hi All, In windows OS, "program files" folder in windows is protected one, means, only administrator can modify its contents. I having problem...
0
by: babaidebnath | last post by:
I want to give my application data folder kaspersky antivirus like security. Where I can add a folder but cant change any content or create any file....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.