473,657 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_US ER\Volatile Environment\APP DATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationD ataFolder() As String
Dim AppDataRegKey As Microsoft.Win32 .RegistryKey =
Microsoft.Win32 .Registry.Curre ntUser.CreateSu bKey("Volatile Environment")
If AppDataRegKey.G etValue("APPDAT A") Is Nothing Then
MessageBox.Show ("Error: Application Data Path not found",
"Error", MessageBoxButto ns.OK, MessageBoxIcon. Asterisk)
Else
Return CType(AppDataRe gKey.GetValue(" APPDATA"), String)
End If
End Function
Thanks for any assistance,
Tim Failes
Advanced User Systems
Jul 21 '05 #1
2 29871
Tim,

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

Environment.Get FolderPath(Spec ialFolder.Appli cationData)

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

HTH,

Alexander Shirshov
"Tim Failes" <Ti*******@disc ussions.microso ft.com> wrote in message
news:F3******** *************** ***********@mic rosoft.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_US ER\Volatile Environment\APP DATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationD ataFolder() As String
Dim AppDataRegKey As Microsoft.Win32 .RegistryKey =
Microsoft.Win32 .Registry.Curre ntUser.CreateSu bKey("Volatile Environment")
If AppDataRegKey.G etValue("APPDAT A") Is Nothing Then
MessageBox.Show ("Error: Application Data Path not found",
"Error", MessageBoxButto ns.OK, MessageBoxIcon. Asterisk)
Else
Return CType(AppDataRe gKey.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.Get FolderPath(Spec ialFolder.Appli cationData)

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

HTH,

Alexander Shirshov
"Tim Failes" <Ti*******@disc ussions.microso ft.com> wrote in message
news:F3******** *************** ***********@mic rosoft.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_US ER\Volatile Environment\APP DATA - is this a valid way to
obtain the Application Data Folder?

Protected Function GetApplicationD ataFolder() As String
Dim AppDataRegKey As Microsoft.Win32 .RegistryKey =
Microsoft.Win32 .Registry.Curre ntUser.CreateSu bKey("Volatile Environment")
If AppDataRegKey.G etValue("APPDAT A") Is Nothing Then
MessageBox.Show ("Error: Application Data Path not found",
"Error", MessageBoxButto ns.OK, MessageBoxIcon. Asterisk)
Else
Return CType(AppDataRe gKey.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
4350
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 and Settings\\\\tigger\\\\My Documents\\\\Visual Studio Projects\\\\theProgram\\\\Report.rpt"; but i wish to deploy the program how do i reference the report after i have deployed it.
13
12713
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 my application are stored in the system registry's HKEY_CURRENT_USER section) When the xml file and news folder are created by my application running under Windows XP, the new folder and the xml file have permissions set for Everyone to read...
1
1863
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 the path to the directory. The target directory does exist in the other profile. Can anyone suggest a way around this whilst keeping my code as compliant as possible?
2
440
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 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...
0
1597
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 does not have an "Application Data" folder, is this true? If that is the case, is there some other way to tell the service to perhaps run from the administartor account, so that I can use the admin's "Application Data" folder? Kind Regards,
1
2210
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 permissions on the directory so that when they are initially created, "Everyone" has full control, even if the logged in user (i.e. the one creating them) is restricted. Thanks - Fred (using VS 2005 Pro)
4
5194
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
3178
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 data" folder. Can anybody tell me whether it is protected or not ? I want to access its contents wihtout any administrative privilages, i.e. restricted user account ( windows OS).
0
1158
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 security privilege but it just does not working only for this kaspersky data folder. I can only modify data when I turning off "Self protection option". I just want to give same type of security into my application data folder. I know how to give security...
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.