Board index » cppbuilder » FileExsists doesn't work properly

FileExsists doesn't work properly

Hi there,
i was using the FileExists() function, to... check if a file exists :) but
passing by parameter a string as "foo.jpg", it returns me that file
exsists too!
I fear it uses some "current directory" variable in somewhere, because
effectively in current directory there is a file named foo.jpg...
How can I set that Current Directory variable to a blank one??
Tnx in advance, Jonny
 

Re:FileExsists doesn't work properly


Use SetCurrentDir("xxx") to set it to where you want.
There will always be a current directory under windows and FileExists will
always assume it if a full path is not given.

HTH Pete

Quote
"Nightshade" <nightsh...@tiscalinet.it> wrote in message

news:pan.2002.11.15.11.26.06.893527@tiscalinet.it...
Hi there,
i was using the FileExists() function, to... check if a file exists :) but
passing by parameter a string as "foo.jpg", it returns me that file
exsists too!
I fear it uses some "current directory" variable in somewhere, because
effectively in current directory there is a file named foo.jpg...
How can I set that Current Directory variable to a blank one??
Tnx in advance, Jonny

Re:FileExsists doesn't work properly


Nightshade,

Quote
> I fear it uses some "current directory" variable in somewhere

It will use the current working directory, yes.

Personally I have never used the CWD, even in DOS, and I can't
understand why anyone would wish to use it under Windows at all.

Quote
> How can I set that Current Directory variable to a blank one??

Look up ChDir() in the help.

Better yet though always, /always/, *always* work with fully
qualified paths. The first thing you should do with a file path that
has come from outside of your application is ensure it is fully
qualified.

ExpandFileName() is your friend. Use it :)
--
Andrue Cope
[Bicester, UK]

Team Thai Kingdom

Other Threads