>This my first starting a new topic in English.
>I want to ask if I want to judge whether a file exists how I should do.
I program with C++.
Thank you.
Open the file (probably for reading, if that's what you intend doing
with it) with fopen(). If it works, the file exists. If it doesn't
work, the file may not exist, or you may be prohibited from accessing
it. WHY did you want to know if it exists? And remember, just
because it existed when you checked it doesn't mean it will still
exist the next time you try to open it.
There are a couple of other approaches which might get you more
information (but are generally considered to have destructive side
effects). For example, remove() it. If it succeeds, the file used
to exist. Try fopen(name, "w"). If it succeeds, either the data
in the file used to exist or you just created an empty file.
It is a feature of many operating systems that you are not allowed
to know whether certain files (e.g. those in protected directories)
exist or not, so you can't always get a completely definite answer
to this question.