473,598 Members | 3,128 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 29866
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
12710
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
1859
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
5193
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
3160
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
7985
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
8389
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...
0
8393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8048
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
6713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5848
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5438
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
3896
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...
1
2411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.