NetNomad312
Technical User
I didn't want to bring this one here because I thought it was so simple... and at one point I thought I found the solution.
My original problem was: my program would always save its INI in C:\, because I copied my method of "checking if the INI exists and if not create it" from a tutorial that I have since lost the address of. It basically consisted of defining "temp$", setting it to Dir([full file path]), and then, "If temp$ <> [filename] Then (create it)". But I recently redesigned the program to be a bit easier to use, and I plan to give this version to more people. So an INI that's permenantly stuck in C:\ is not really an option anymore.
Looking through the MSDN library for something I could use, I came across "CurDir." I thought this is what I needed, and rewrote the code this way:
Turns out CurDir isn't what I thought it was. It seems to change whenever I used one of the browse boxes in my program... and then the next time I run the program it keeps telling me it created a new INI. I'm guessing "CurDir" refers to the directory Windows is currently looking at as opposed to the directory my program is in, is that right?
I guess it's possible to use "File" objects to do some of this... maybe. I dunno. As you've probably figured out by now, I know very little about this. I was never taught anything about working with files in the single class I once took that used VB6 (which was a highschool class), and so far I've never used the FileSystemObject in my program; I've been using some functions that I copied from that tutorial that I forgot the name of... functions that use kernel32 to read from and write to INI files somehow. This is all I really know, and I'm trying to figure out the rest of it as I go (which is why I regret having to bring such a dumb question here). What I can't figure out is, how do I get it to say "my directory" + [filename]?
My original problem was: my program would always save its INI in C:\, because I copied my method of "checking if the INI exists and if not create it" from a tutorial that I have since lost the address of. It basically consisted of defining "temp$", setting it to Dir([full file path]), and then, "If temp$ <> [filename] Then (create it)". But I recently redesigned the program to be a bit easier to use, and I plan to give this version to more people. So an INI that's permenantly stuck in C:\ is not really an option anymore.
Looking through the MSDN library for something I could use, I came across "CurDir." I thought this is what I needed, and rewrote the code this way:
Code:
Dim fso As New FileSystemObject
If fso.FileExists("Config.ini") = False Then
(create new ini, etc.)
MsgBox (message here saying new ini was created)
Else
lpFileName = CurDir + "\Config.ini"
(load data from INI)
End if
Turns out CurDir isn't what I thought it was. It seems to change whenever I used one of the browse boxes in my program... and then the next time I run the program it keeps telling me it created a new INI. I'm guessing "CurDir" refers to the directory Windows is currently looking at as opposed to the directory my program is in, is that right?
I guess it's possible to use "File" objects to do some of this... maybe. I dunno. As you've probably figured out by now, I know very little about this. I was never taught anything about working with files in the single class I once took that used VB6 (which was a highschool class), and so far I've never used the FileSystemObject in my program; I've been using some functions that I copied from that tutorial that I forgot the name of... functions that use kernel32 to read from and write to INI files somehow. This is all I really know, and I'm trying to figure out the rest of it as I go (which is why I regret having to bring such a dumb question here). What I can't figure out is, how do I get it to say "my directory" + [filename]?