2 replies
by lastorck
ok, but i didn't try it. Hope it ll work properly. I use VC++5.0. Good luck!
#include
#include
#include
#include
int MyDelDir(const string& path)
{
string _path(path + "\\*.*");
WIN32_FIND_DATA data;
HANDLE hd = FindFirstFile(_path.c_str(), &data);
if(hd != INVALID_HANDLE_VALUE)
do
{
if(data.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
if(data.cFileName[0] != '.') //not current & up
MyDelDir(path + "\\" + data.cFileName);
}
else
{
if(!DeleteFile((path + "\\" + data.cFileName).c_str())
break; //error!!!
}
}while(FindNextFile(hd, &data));
if(GetLastError() != ERROR_NO_MORE_FILES)
return 1; //error!!!
if(!FindClose(hd))
return 2; //error!!!
if(!RemoveDirectory(path.c_str()))
return 3; //error!!!
return 0; //OK
}
by hueristic
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending