| View previous topic :: View next topic |
| Author |
Message |
sword Guest
|
Posted: Sun Jul 30, 2006 9:11 am Post subject: Check whether a file exists |
|
|
How can I check whether a file exists? |
|
| Back to top |
|
 |
sword Guest
|
Posted: Sun Jul 30, 2006 9:11 am Post subject: Re: Check whether a file exists |
|
|
Thanks |
|
| Back to top |
|
 |
Ivan Vecerina Guest
|
Posted: Sun Jul 30, 2006 9:11 am Post subject: Re: Check whether a file exists |
|
|
"sword" <solitudesword (AT) gmail (DOT) com> wrote in message
news:1154241363.816998.8750 (AT) m73g2000cwd (DOT) googlegroups.com...
: How can I check whether a file exists?
You'll get the same answer here as in the C NG ;)
The portable way to check for this is to try to open
the file (you may use ifstream, or fopen as in C)
to check if it succeeds, then close it immediately.
Two main issues are:
- various operating systems may have various
restrictions on visibility or accessibility
of files within a given storage/directory.
- on a multitasking OS, a file that exists
at a given time may be deleted by the next
statement.
So in general, best is to just try to use the file,
and report the error at that point.
hth-Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com |
|
| Back to top |
|
 |
Bruintje Beer Guest
|
Posted: Sun Jul 30, 2006 9:11 am Post subject: Re: Check whether a file exists |
|
|
"sword" <solitudesword (AT) gmail (DOT) com> schreef in bericht
news:1154241363.816998.8750 (AT) m73g2000cwd (DOT) googlegroups.com...
| Quote: | How can I check whether a file exists?
|
man access
John |
|
| Back to top |
|
 |
|