Results 1 to 5 of 5

Thread: default directory question

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    6

    default directory question

    I am developing an app that I am using an .ini file to save some settings to. I am getting some confsion about where the files goes based on the path I give it. 1st of all would there be any difference in saying "settings.ini" and "./settings.ini"??? 2nd, When I dont' give it a specific directory to goto It seems to change where isn't going for no reason. Sometimes its where the VB file is located, and sometimes its c:\windows and sometimes its where VB is installed to. I don't want to use a specific path cause I want it to go where ever the program is installed to and I don't want that path to be set in stone. I tried to search and find more info on this didn't find much. Oh, and what about app.path? Does that give the current working directory or will that ALWAYS give the path to where the program is located, if so thats what I need right?? Thanks.

  2. #2
    Member
    Join Date
    Mar 2007
    Posts
    44

    Re: default directory question

    It was not vb's problem, because the API function WritePrivateProfileString/WriteProfileString was work on windows 3.x what didn't have registry, and for the reason:save system resource, the default path was windows path(most C:\windows).
    .\settings.ini was true(not ./settings.ini)
    ..\settings.ini was the path under current App.Path, such as App.Path = "D:\first\second", ..\settings.ini = "D:\first\setting.ini"

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: default directory question

    HI,
    I use this Path.
    Code:
    Path= App.Path & "\settings.ini"
    This way my .ini file is always in the directory where the application (either the .vbp for running in the IDE or the .exe) is.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    Member
    Join Date
    Mar 2007
    Posts
    44

    Re: default directory question

    Code:
    Path= App.Path & "\settings.ini"
    It may not work well always.If you EXE was work in driver root,such as D:\, then you ini file path will become D:\\settings.ini, an error will occur.

  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: default directory question

    Quote Originally Posted by tanchuhan
    It may not work well always.If you EXE was work in driver root,such as D:\, then you ini file path will become D:\\settings.ini, an error will occur.
    I usually go with an IIf to get around that.
    Code:
    Path = IIf(Right(App.Path, 1) = "\", App.Path & "settings.ini", App.Path & "\settings.ini")

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