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!

Storing files - where?

Status
Not open for further replies.

serializer

Programmer
May 15, 2006
143
SE
I have a client application that I build for non-admin usage. I want to store some settings files that are shared across users (all users can read/write). Where should I store them?

thanks
 
Are all the users on the same computer or do they use different machines?

If they are all on the same machine, either store them in a subdirectory in the application folder or put them in the All Users folder of Documents and Settings (XP).

If they are settings to be shared across multiple computers then I would recommend putting them on a network share or in a common DB.

 
If these settings are going to be shared by all users you'd probably be OK going with the age old method of storing them in the same directory as the PE.
 
unfortunately 2003 and vista don't allow that by default, and i must say i agree that the "program files" tree probably shouldn't be writable by non-admins. (cue long and bitter rant about the inability of cognos programmers to understand even the first thing about Windows permissions...)

and each release of windows seems to write its user parameters to a different folder tree. is there a consistent environment variable one could use?


mr s. <;)

 
Yes there are several constants you can use, however none of them are as helpful as I would like. I have been looking for a way to store version independent, all user files to a non admin writable area, but the best I have come up with is to take something like Application.CommonAppDataPath, and go up a directory. becaues every release will create a new folder based on the version number.

here's the output of just about every folder path constant in.Net and what they map to on XP and Vista: (To make this easier to read you might want to cut and paste this into notepad)

Code:
XP:

Application.CommonAppDataPath: 	    C:\Documents and Settings\All Users\Application Data\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.CommonAppDataRegistry: 	HKEY_LOCAL_MACHINE\Software\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.ExecutablePath: 	      C:\Documents and Settings\neiln\Desktop\WindowsFormsApplication1.exe
Application.LocalUserAppDataPath: 	C:\Documents and Settings\neiln\Local Settings\Application Data\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.StartupPath: 		        C:\Documents and Settings\neiln\Desktop
Application.UserAppDataPath: 	      C:\Documents and Settings\neiln\Application Data\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.UserAppDataRegistry: 	  HKEY_CURRENT_USER\Software\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0

Microsoft.VisualBasic.FileIO.SpecialDirectories.AllUsersApplicationData		  C:\Documents and Settings\All Users\Application Data\ConsoleApplication1\ConsoleApplication1\1.0.0.0
Microsoft.VisualBasic.FileIO.SpecialDirectories.CurrentUserApplicationData	C:\Documents and Settings\neiln\Application Data\ConsoleApplication1\ConsoleApplication1\1.0.0.0
Microsoft.VisualBasic.FileIO.SpecialDirectories.Desktop				              C:\Documents and Settings\neiln\Desktop
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyDocuments			            C:\Documents and Settings\neiln\My Documents
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyMusic				              C:\Documents and Settings\neiln\My Documents\My Music
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyPictures			            C:\Documents and Settings\neiln\My Documents\My Pictures
Microsoft.VisualBasic.FileIO.SpecialDirectories.ProgramFiles			          C:\Program Files
Microsoft.VisualBasic.FileIO.SpecialDirectories.Programs			              C:\Documents and Settings\neiln\Start Menu\Programs
Microsoft.VisualBasic.FileIO.SpecialDirectories.Temp				                C:\Documents and Settings\neiln\Local Settings\Temp


Vista:

Application.CommonAppDataPath:      C:\ProgramData\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.CommonAppDataRegistry:  HKEY_LOCAL_MACHINE\Software\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.ExecutablePath:         C:\Users\Neil\Desktop\CS Projects\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.EXE
Application.LocalUserAppDataPath:   C:\Users\Neil\AppData\Local\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.StartupPath:            C:\Users\Neil\Desktop\CS Projects\WindowsFormsApplication1\bin\Debug
Application.UserAppDataPath:        C:\Users\Neil\AppData\Roaming\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0
Application.UserAppDataRegistry:    HKEY_CURRENT_USER\Software\WindowsFormsApplication1\WindowsFormsApplication1\1.0.0.0

Microsoft.VisualBasic.FileIO.SpecialDirectories.AllUsersApplicationData     C:\ProgramData\ConsoleApplication1\ConsoleApplication1\1.0.0.0
Microsoft.VisualBasic.FileIO.SpecialDirectories.CurrentUserApplicationData  C:\Users\Neil\AppData\Roaming\ConsoleApplication1\ConsoleApplication1\1.0.0.0
Microsoft.VisualBasic.FileIO.SpecialDirectories.Desktop                     C:\Users\Neil\Desktop
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyDocuments                 C:\Users\Neil\Documents
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyMusic                     D:\Music
Microsoft.VisualBasic.FileIO.SpecialDirectories.MyPictures                  C:\Users\Neil\Pictures
Microsoft.VisualBasic.FileIO.SpecialDirectories.ProgramFiles                C:\Program Files
Microsoft.VisualBasic.FileIO.SpecialDirectories.Programs                    C:\Users\Neil\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Microsoft.VisualBasic.FileIO.SpecialDirectories.Temp                        C:\Users\Neil\AppData\Local\Temp
 
How about using IsolatedStorage? Might work for what you need .

Regards,

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top