Jump to content
Sign in to follow this  
hairyllama

FileExists and or IniRead not working for me..

Recommended Posts

hairyllama

So i just found AutoIt and have been working away at a simple test script as i learn. I decided to add an .ini file to make things easier. However even though i have verified that the ini file is named properly and placed in the correct directory when i use FileExists it won't find the file. I have tried using...

$iniFile = @scriptDir & "\default.ini"

I also have tried naming the ini file the same as the script and then..

$iniFile=stringleft(@ScriptName,stringlen(@scriptname)-4) & ".ini"

But no matter what i try it isn't finding the file. The ini file IS in the appropriate directory. and i do have #include <file.au3> so any help is appreciated.

Edited by hairyllama

Share this post


Link to post
Share on other sites
ajag

So i just found AutoIt and have been working away at a simple test script as i learn. I decided to add an .ini file to make things easier. However even though i have verified that the ini file is named properly and placed in the correct directory when i use FileExists it won't find the file. I have tried using...

$iniFile = @scriptDir & "/default.ini"

I also have tried naming the ini file the same as the script and then..

$iniFile=stringleft(@ScriptName,stringlen(@scriptname)-4) & ".ini"

But no matter what i try it isn't finding the file. The ini file IS in the appropriate directory. and i do have #include <file.au3> so any help is appreciated.

Hi hairyllama,

Is this really in your code?

$iniFile = @scriptDir & "/default.ini"   
                         ^

It should be a backslash "\"

A-Jay

Edited by ajag

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites
hairyllama

Hi hairyllama,

Is this really in your code?

$iniFile = @scriptDir & "/default.ini"   
                         ^

It should be a backslash "\"

A-Jay

Oops yes i am using backslash just a typo when writing the first post! I shall edit it if i can.

Share this post


Link to post
Share on other sites
ajag

So it is better to post a snippet of your real code. It will help to see what's going wrong.

Did you try to type the full path like $IniFile = "D:\Test\default.ini"?

A-Jay

Edited by ajag

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites
hairyllama

#include <file.au3>

if not FileExists("C:\default.ini") Then  
msgbox(0,"","The ini file could not be found at following location: root")  
exit  
EndIf

Just to test and make sure i wasn't insane. I did that, and yes the file default.ini is placed in the C:\ root. So i have no idea whats going on lol

Share this post


Link to post
Share on other sites
ajag

#include <file.au3>

if not FileExists("C:\default.ini") Then  
msgbox(0,"","The ini file could not be found at following location: root")  
exit  
EndIf

Just to test and make sure i wasn't insane. I did that, and yes the file default.ini is placed in the C:\ root. So i have no idea whats going on lol

Then you have to call a MD (hehe). Your example works fine for me...

A-Jay


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites
hairyllama

Then you have to call a MD (hehe). Your example works fine for me...

A-Jay

Rats thats what i was afraid of. Guess something is screwed up with my system then. Laaaame ill try it on one of my other pc's. Thanks for the testing.

Share this post


Link to post
Share on other sites
somdcomputerguy

#include <file.au3>

if not FileExists("C:\default.ini") Then  
msgbox(0,"","The ini file could not be found at following location: root")  
exit  
EndIf

Just to test and make sure i wasn't insane. I did that, and yes the file default.ini is placed in the C:\ root. So i have no idea whats going on lol

file.au3 doesn't need to be included for the FileExists function. If the file does exist at that location, then that script will just end without displaying a message, is that what's happening? Try this simpler rendition of that code if necessary.

If FileExists("C:\default.ini") Then MsgBox(0, "", "The file exists")
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
saywell

It seems that @SCRIPTDIR includes a backslash when it's being run from root directory of a drive.

Try

MsgBox (0, "backslash or not?", @ScriptDir)

when run from the root of a drive [eg memory stick for test purposes], then from a subfolder.

This isn't in the documentation, which just says:

@ScriptDir - Directory containing the running script. (Result does not contain a trailing backslash)

William

Edited by saywell

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×