|
-
Jan 16th, 2005, 02:16 PM
#1
Thread Starter
Fanatic Member
Where to save files?
In most applications I develop I use XML files to store information in (the settings / preferences for example). Now usually I store this file in the App.Path folder, but I fear that's not the best solution. If an app is used in a network environment and the user has no administration rights, he may not be able to access the harddisk on which the app resides (and so the settings can't be saved).
Where else could the file be stored? What's good practice here?
Author for Visual Basic Web Magazine
-
Jan 16th, 2005, 02:19 PM
#2
Banned
Re: Where to save files?
in the My documents folder?
-
Jan 16th, 2005, 02:29 PM
#3
Re: Where to save files?
This code will return the path to the "My Documents" folder.
VB Code:
Private Declare Function SHGetSpecialFolderPath _
Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
ByVal hwnd As Long, _
ByVal pszPath As String, _
ByVal csidl As Long, _
ByVal fCreate As Long) As Long
Private Const CSIDL_PERSONAL As Long = &H5
Private Function GetPath() As String
Dim sPath As String
sPath = Space$(260)
Call SHGetSpecialFolderPath(0, sPath, CSIDL_PERSONAL, False)
GetPath = Left$(sPath, InStr(sPath, vbNullChar) - 1)
End Function
Cheers,
-
Jan 16th, 2005, 02:54 PM
#4
Thread Starter
Fanatic Member
Re: Where to save files?
Thanks for the code and the suggestion, but the My Documents folder doesn't seem like such a good choice to me. Nobody wants a useless XML file in their personal directory, right? :S
I've found that many applications use the Documents and Settings\UserName\Application Data directory. Do all Windows versions have an AppData directory?
Author for Visual Basic Web Magazine
-
Jan 16th, 2005, 03:24 PM
#5
Re: Where to save files?
Well you should of course create your own subdirectory. But if you want to use the AppData directory (which is probably a better choice) just change CSIDL_PERSONAL to CSIDL_APPDATA (= &H1A). I don't know if Win98 has an appdata but I think so. If I remember correctly it has a Common directory under the System directory but it was a long time since I used Win98.
-
Jan 16th, 2005, 03:25 PM
#6
-
Jan 16th, 2005, 06:25 PM
#7
Thread Starter
Fanatic Member
Re: Where to save files?
Thanks, I'll go with the AppData directory then.
Author for Visual Basic Web Magazine
-
Jan 16th, 2005, 08:07 PM
#8
Re: Where to save files?
I always find it a consideration to save files where they will be in a normal path for backups. (for people who actually do them).
i hate some programs that put "data" files in the windows or system directory so they don't get backup regularly.
rgds pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|