Re: is file exist
- From: "ma" <ma@xxxxxxxxxxx>
- Date: Mon, 1 May 2006 14:41:40 +0100
"Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx> wrote in message
news:%23%23HytNSbGHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
ma wrote:
I need to check for existence of a file in current directory. I did
write my code that consists of opening it and if opening fails, I
could understand that the file doesn't exist. It is working but I
don't think it is the best solution. What is the best solution? Is
there any function that I can use for this purpose? Is there any
source code or sample on this?
Generally speaking, if you need to read a file, opening it for reading and
checking success is what you are supposed to do. If you need to write
a file, opening it for writing and checking success is what you're
supposed
to do. What do you need to check the existence of the file for? Is it
used
as some kind of semaphore? Then it probably contains some information
that
might be useful, so open it for reading and read (if it opens).
There are file functions in Windows API, like CreateFile, which extend the
plain ol' "open" functionality of the standard C library. Check it out.
And I bet the manual does contain a decent example of using 'CreateFile'.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Hello,
I have a library with a function in it that get a file name and download
it to a hardware. The problem with this function is that if it fails it
doesn't give me any clue why it fails. One important way that it may fail is
when the file isn't available. So I need to check if the file is exist.
One other situation that I can see if I want to see if there is a file in
path and if it is , what is its full path. How can I do this? I know that I
can use findfile and findnext, but is there any better way to do this?
best regards
.
- Follow-Ups:
- Re: is file exist
- From: Victor Bazarov
- Re: is file exist
- References:
- is file exist
- From: ma
- Re: is file exist
- From: Victor Bazarov
- is file exist
- Prev by Date: Re: is file exist
- Next by Date: Re: is file exist
- Previous by thread: Re: is file exist
- Next by thread: Re: is file exist
- Index(es):
Relevant Pages
|