| View previous topic :: View next topic |
| Author |
Message |
Murp|e
Joined: 12 Jan 2007 Posts: 261 Location: Norway
|
Posted: Sun Feb 03, 2008 10:51 pm Post subject: Problems using FileExist(FilePattern) |
|
|
I am trying to set the variable sfilename to blank if sfullpath is a folder. It's really simple, but for some reason I haven't been able to get it to work at all.
This is my code:
| Code: | if InStr(FileExist(sfullpath), "D")
{
msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
sfilename =
} |
While debugging I tried this code:
| Code: | AttributeString := FileExist(sfullpath)
msgbox, File or folder: "%sfullpath%"`nAttributes: "%AttributeString%" |
AttributeString is almost always blank, it returned "A" a couple of times, but it never returned a string containing "D" even though I hard coded the variable sfullpath to be the path of a folder. I've sucessfully used the FileExist function to test for folders before, any ideas as to what I could be doing wrong? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Mon Feb 04, 2008 8:10 am Post subject: |
|
|
Check the variable sfullpath before calling InStr()
The following works for me:
| Code: | sfullpath := A_WinDir
if InStr(FileExist(sfullpath), "D")
{
msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
sfilename =
} |
 |
|
| Back to top |
|
 |
Murp|e
Joined: 12 Jan 2007 Posts: 261 Location: Norway
|
Posted: Mon Feb 04, 2008 8:29 am Post subject: |
|
|
SKAN,
Thanks for your reply. Unfortunately it works for me too(!). I've been checking sfullpath over and over again and checking that the paths actually exist by copying them, pasting them into the run box and seeing that the folders open.
Stupid bugz.... |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Mon Feb 04, 2008 8:54 am Post subject: |
|
|
| Murp|e wrote: | | I've been checking sfullpath over and over again and checking that the paths actually exist by copying them, pasting them into the run box and seeing that the folders open. |
er.. Maybe you are using := and not wrapping the path with double quotes ?
| Code: | EnvGet, SD, SystemDrive
sfullpath=%SD%\Documents and Settings\%A_UserName%\Local Settings\Temp
MsgBox, % sFullPath
if InStr(FileExist(sfullpath), "D")
{
msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
sfilename =
} |
 |
|
| Back to top |
|
 |
|