C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check whether a file exists

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
sword
Guest





PostPosted: Sun Jul 30, 2006 9:11 am    Post subject: Check whether a file exists Reply with quote



How can I check whether a file exists?
Back to top
sword
Guest





PostPosted: Sun Jul 30, 2006 9:11 am    Post subject: Re: Check whether a file exists Reply with quote



Thanks
Back to top
Ivan Vecerina
Guest





PostPosted: Sun Jul 30, 2006 9:11 am    Post subject: Re: Check whether a file exists Reply with quote



"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





PostPosted: Sun Jul 30, 2006 9:11 am    Post subject: Re: Check whether a file exists Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.