Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Local Files

Status
Not open for further replies.

crystalkiwibruce

Programmer
Feb 16, 2011
104
0
0
NZ
Microsoft have been discouraging us from saving data in the Program Files folder where the application is installed. On Windows 7 and Vista, that folder is protected and we are told to use c:\ProgramData\CompanyName\AppName for files used by all users on the machine.

Vista and Windows 7 also have a Users\Public Folder. Can I use that?

On XP, Server 2003, and older, there is no ProgramData or Users folder. I fell into a trap recently where Server 2003 has some Vista rules, but no place to put my data, while on XP my application happily uses the program folder for it's config files.

Where should I save them on XP and Server 2003? Is there a general System call to find a public folder on all vesions of windows?

Despite Microsoft marketing efforts there are plenty of people running these older versions of Windows, and I'd like my applications to run on them. What should I do? What versions should I use what folders to save my files.
 
Keep in mind that just because a specific version of Windows has a 'public' folder, it doesn't mean that the folder is visible to other users. If the file sharing option is turned off, that folder is only visible to the individual user.

In addition, window versions earlier than Vista do not have public folders. There is typically a 'shared' folder or any other folder can be set to a shared status depending on the folder properties and permissions.

This also depends on how the computers are set up. It is a direct link from computer to computer, are certain files or programs being accessed from a server or are the programs run from a server such as Citrix.

If at first you don't succeed, then sky diving wasn't meant for you!
 
This should give you what you need:

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

This typically returns "C:\Documents and Settings\All Users\Application Data" on XP, and "C:\ProgramData" on Vista and Win7.

Here's a link to all of the Environment.SpecialFolder enumerations:




I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top