VioFX Posted May 13, 2011 Share Posted May 13, 2011 (edited) Okay so I've got my program here and want to give it to a few friends, so I can't specify exactly what folder it will be on. So how can I open a file using FileOpen() from a subfolder where the .exe is located? Here's what I'm using: If _GUICtrlTreeView_GetSelected($mainTree, $subfolderItem) Then $file = FileOpen("\Subfolder\Subfolder.ini", 0) Else EndIf Using this as a test to see if it opens from "\Subfolder\" which is where the .exe is located. But whenever this function runs it just closes my program, so I assume it couldn't find the file. Because when I replace it with this: $file = FileOpen("Subfolder.ini", 0) and put the "Subfolder.ini" in the same folder as the .exe it runs fine and does everything it's supposed to. I've searched around and haven't really found someone with the same question because every post I find that has to do with this have people who set a specific folder to look in. I'm trying to find it from a subfolder that's located anywhere the .exe is placed. Probably the simplest issue which I'm going to be very embarrassed with... but I just can't get it. Edited May 13, 2011 by VioFX Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 14, 2011 Share Posted May 14, 2011 (edited) Having "\" at the beginning of the string indicates it starts at root, as in C:\Subfolder. If you leave the starting backslash off, then it can be a relative path. So perhaps one of these: $file = FileOpen("Subfolder\Subfolder.ini", 0) $file = FileOpen(".\Subfolder\Subfolder.ini", 0) $file = FileOpen(@Workingdir & "\Subfolder\Subfolder.ini", 0) Edited May 14, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
VioFX Posted May 14, 2011 Author Share Posted May 14, 2011 Oh wow.. I had a feeling it was something that small. Well thanks lol Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 14, 2011 Share Posted May 14, 2011 Okay so I've got my program here and want to give it to a few friends, so I can't specify exactly what folder it will be on. So how can I open a file using FileOpen() from a subfolder where the .exe is located?If you by .exe mean your AutoIt script, use @ScriptDir .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now