-
May 21st, 2008, 12:28 PM
#1
DeleteDirectory
Hi all, Im trying to figure out how to use the DeleteDirectory API. I went to MSDN and it looks pretty straight forward. But i got a undeclared identifier error.
my code
Code:
#include <windows.h>
int main(){
DeleteDirectory("C:\\test", NULL, NULL, NULL);
return 0;
}
I was just trying to be simple so i could figure out how to use it. Any suggestions are greatly appreciated.
The error:
[quote]
error C2065: 'DeleteDirectory' : undeclared identifier
[/code]
Thanx in advance!
-
May 21st, 2008, 12:30 PM
#2
Re: DeleteDirectory
Originally Posted by dellthinker
error C2065: 'DeleteDirectory' : undeclared identifier
That's because there's no such API. I take it you're referring to RemoveDirectory...
-
May 21st, 2008, 12:32 PM
#3
Re: DeleteDirectory
The MSDN I have doesn't list a DeleteDirectory API.
-
May 21st, 2008, 05:46 PM
#4
Re: DeleteDirectory
Thanx for your replies. DeleteDirectory() seems to be a working API. But according to MSDN.
RemoveDirectory Function
Deletes an existing empty directory.
To perform this operation as a transacted operation, use the RemoveDirectoryTransacted function.
So what if the dir has files inside of it? How would i manage to delete one with files in it?
-
May 21st, 2008, 05:51 PM
#5
Re: DeleteDirectory
Originally Posted by dellthinker
DeleteDirectory() seems to be a working API.
Say what?
Originally Posted by dellthinker
So what if the dir has files inside of it? How would i manage to delete one with files in it?
FindFirstFile, FindNextFile, DeleteFile.
-
May 21st, 2008, 06:08 PM
#6
Re: DeleteDirectory
So what if the dir has files inside of it? How would i manage to delete one with files in it?
I used SHFileOperation to delete all the files.
Code:
SHFILEOPSTRUCT fileOpStruct;
fileOpStruct.hwnd = this->m_hWnd;
fileOpStruct.wFunc = FO_DELETE;
fileOpStruct.pFrom = L"path_to_your_folder\*.*"
fileOpStruct.pTo = 0;
fileOpStruct.fFlags = FOF_SIMPLEPROGRESS;
fileOpStruct.lpszProgressTitle =L"Deleting old files";
int res = SHFileOperation(&fileOpStruct);
if (res || fileOpStruct.fAnyOperationsAborted)
{
// error or user doesn't confirm deleting
}
else
{
// files were deleted, now directory can be deleted.
}
-
May 21st, 2008, 09:35 PM
#7
Re: DeleteDirectory
Originally Posted by dellthinker
Thanx for your replies. DeleteDirectory() seems to be a working API. But according to MSDN.
So what if the dir has files inside of it? How would i manage to delete one with files in it?
You said DeleteDirectory, but posted MSDN saying RemoveDirectory.
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
|