|
-
May 10th, 2007, 05:40 AM
#1
How to check directory's presence?
Hi,
I need to see if a particular directory is present or not, at the specified path.
For a file we can do it using fopen() return value but what for a directory (for all platforms)?
--Virendra--
Last edited by vnyelurkar; May 10th, 2007 at 05:42 AM.
-
May 10th, 2007, 07:40 AM
#2
Re: How to check directory's presence?
What language are you doing this in...PHP? If so, you can use file_exists. It checks for files or directories.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 13th, 2007, 02:51 AM
#3
Re: How to check directory's presence?
PeejAvery,
I am doing this through C++. Here, I want to know if the directory already exists, before calling CreateDirectory() API.
Thanks,
--Virendra--
-
May 13th, 2007, 05:47 AM
#4
Re: How to check directory's presence?
Use CreateFile with dwDesiredAccess==0 and dwCreationDistribution==OPEN_EXISTING.
CreateFile can be used to "open directories".
It should fail if the directory doesn't exist.
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
May 13th, 2007, 05:53 AM
#5
Re: How to check directory's presence?
Ya, this one is better solution.
Thanks a lot........
-
May 13th, 2007, 08:32 AM
#6
Re: How to check directory's presence?
 Originally Posted by vnyelurkar
I am doing this through C++.
Then this belongs in the C++ forum. I would have never been confused if it had been there to start. Glad your problem was solved.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 13th, 2007, 09:34 AM
#7
Re: How to check directory's presence?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
May 13th, 2007, 01:12 PM
#8
Re: How to check directory's presence?
-
May 13th, 2007, 03:24 PM
#9
Re: How to check directory's presence?
The easier one: GetFileAttributes() == FILE_ATTRIBUTE_DIRECTORY.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|