Click here to Skip to main content
11,921,835 members (65,902 online)
Rate this:
Please Sign up or sign in to vote.
See more: VC8.0 C++
How to check whether the folder exists or not?
Posted 26-May-11 1:15am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This will tell you if a FILE or DIRECTORY exists or not...

BOOL FolderExists(CString strFolderName)
  return GetFileAttributes(strFolderName) != INVALID_FILE_ATTRIBUTES;   

Hope this helps...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hey Simply try this,
   MessageBox("Directory is already exist!");
HarishTheLearner 26-May-11 6:30am
Simple and direct solution!My 5
venkatmakam 26-May-11 6:54am
But CreateDirectory will create the directory if it not exists.So it is not useful i think.Any way i countered down vote :-)
SP 24 26-May-11 7:04am
See the OP previous question

Actually he wants to create a directory but before creating he wants to check that directory is exist or not.
venkatmakam 26-May-11 8:12am
I did not aware of that question.But for checking the existence of directory i think CreateDirectory is not a good solution,since we have some more alternates.:-)
SP 24 26-May-11 8:21am
Yes I know that's why send you the link :).
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

santosh dhanawade 27-May-11 0:16am
Hey OP NEED simple solution
venkatmakam 27-May-11 5:02am
passing file path as argument and checking the return value...,I think it is a simple solution :).
santosh dhanawade 27-May-11 0:16am
Sorry for down vote

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 538
1 Dave Kreskowiak 260
2 Sergey Alexandrovich Kryukov 173
3 phil.o 170
4 RyanDev 134
0 OriginalGriff 7,036
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,286
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web03 | 2.8.151120.1 | Last Updated 26 May 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100