Results 1 to 8 of 8

Thread: Where to save files?

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Smile 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

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2

    Re: Where to save files?

    in the My documents folder?

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Where to save files?

    This code will return the path to the "My Documents" folder.
    VB Code:
    1. Private Declare Function SHGetSpecialFolderPath _
    2.  Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
    3.  ByVal hwnd As Long, _
    4.  ByVal pszPath As String, _
    5.  ByVal csidl As Long, _
    6.  ByVal fCreate As Long) As Long
    7.  
    8. Private Const CSIDL_PERSONAL As Long = &H5
    9.  
    10. Private Function GetPath() As String
    11.     Dim sPath As String
    12.    
    13.     sPath = Space$(260)
    14.     Call SHGetSpecialFolderPath(0, sPath, CSIDL_PERSONAL, False)
    15.     GetPath = Left$(sPath, InStr(sPath, vbNullChar) - 1)
    16. End Function
    Cheers,

  4. #4

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    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

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Where to save files?

    XP Home does.

  7. #7

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: Where to save files?

    Thanks, I'll go with the AppData directory then.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width