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.
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"
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.
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.
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")