|
-
May 6th, 2002, 12:17 AM
#1
How can i check whether a particular directory exists or not?
How can i check if some directory exists or not.
For example if i want to check whether C:\TEMP exists or not. Also if this directory does not exist, how can i create this directory.
-
May 6th, 2002, 12:35 AM
#2
Re: How can i check whether a particular directory exists or not?
Hi,
You can try the following,
if(CreateDirectory("C:\\temp123",NULL) == 0)
{
if(ERROR_ALREADY_EXISTS ==GetLastError())
AfxMessageBox("Already existing");
}
If the folder doesn't exist it will create it!!
Regards,
Sreedharan.
Regards,
Sreedharan
-
May 6th, 2002, 12:52 AM
#3
Re: How can i check whether a particular directory exists or not?
-
July 11th, 2002, 01:53 PM
#4
What does this mean:
unresolved external symbol __imp__PathIsDirectoryA@4
Get this when using PathIsDirectory()
-
November 27th, 2003, 06:00 AM
#5
Originally posted by mike@spb
What does this mean:
unresolved external symbol __imp__PathIsDirectoryA@4
Get this when using PathIsDirectory()
I get exactly the same thing when using PathIsDirectory. I've included shlwapi.h, specified the shlwapi.lib in the project settings but get this error whenever I included a call to a method in the the lib. What's going on?
-
November 27th, 2003, 09:38 AM
#6
u can use CFile::GetStatus
-
November 27th, 2003, 09:40 AM
#7
I ended up using _access() which has the same results but i still have no idea why I couldn't compile using PathIsDirectory. It must be something to do with project setttings in VS because my colleague created a new project exactly the same as my own one , imported the lib and included the header. Worked first time.
-
November 27th, 2003, 09:44 AM
#8
Here's an alternate suggestion:
Code:
char path[] = "C:\\temp";
SHFILEINFO shFileInfo;
if (SHGetFileInfo((LPCSTR)path, 0,
&shFileInfo, sizeof(SHFILEINFO), SHGFI_TYPENAME) != 0)
{
// Then file or folder exists
:
}
else
{
// File or folder does not exist
:
}
-
April 27th, 2008, 02:12 AM
#9
Re: How can i check whether a particular directory exists or not?
In C#,Its pretty simple.
string destination = @"E:\Songs\sumi songs\fav\";
if (!Directory.Exists(destination))
Directory.CreateDirectory(destination);
C# provides static class "Directory" which is helpfull to do many directory or folder related functionality
-
April 27th, 2008, 04:15 AM
#10
Re: How can i check whether a particular directory exists or not?
My understanding is that you need access to the directory for the temporary files. It it's so, simply call the GetTempPath function.
-
April 27th, 2008, 07:44 AM
#11
Re: How can i check whether a particular directory exists or not?
-
April 27th, 2008, 09:30 AM
#12
Re: MakeSureDirectoryPathExists
One consideration with MakeSureDirectoryPathExists is that it requires one to bring Dbghelp.dll into the address space of one's app, which may be fine if one is using other functions from DbgHelp.dll. One may not wish to load DbgHelp.dll just for the sake of this one function, however.
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
|