|
-
Mar 28th, 2007, 08:38 AM
#1
Thread Starter
New Member
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.
-
Mar 28th, 2007, 08:59 AM
#2
Member
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"
-
Mar 28th, 2007, 09:04 AM
#3
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!
-
Mar 28th, 2007, 09:17 AM
#4
Member
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.
-
Mar 28th, 2007, 10:59 AM
#5
Re: default directory question
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|