473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 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 29844
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. crystalReportViewer1.ReportSource = "C:\\\\Documents...
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 machine. (The uers personal settings associated with...
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 application using runas, when it is unable to resolve...
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 pathname. I have found many references to the...
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 System" account and as far as I know that account...
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 modify and add files to them. How do I set...
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, Bob
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 with "Documents and settings\All Users\Application...
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. I even gave the current user full control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.