debugger? u meant thatthing tat show error when u compile stuff? There's no errors.
Code:
-------------- Build: Debug in testdll ---------------
Compiling: main.cpp
Linking dynamic library: bin\Debug\testdll.dll
Creating library file: bin\Debug\libtestdll.a
Output size is 1.26 MB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings
Your I dea was pretty good but there was 1 small problem, Instead of going upwards in dir tree it went backwards
I executed ths dll func in D:\My Documents\cpp\dll\testdll\bin\Debug\New folder
and it deleted all files in.
- New folder
- Debug
- bin
- testdll
- dll
- cpp
- My Documents
I lost all files from my documents :S I even don't know if I had there something valueable but it didn't delete the dirs.
But bigger problem is that
D:\My Documents\cpp\dll\testdll\bin\Debug\New folder\test\New folder (2)\ still contains it's files. how to fix that?
That's the code.
Code:
void DLL_EXPORT DeleteAllFiles(const LPCSTR folderPath)
{
//MessageBoxA(0, folderPath, "DLL Message", MB_OK | MB_ICONINFORMATION);
char fileFound[256];
WIN32_FIND_DATA info;
HANDLE hp;
sprintf(fileFound, "%s\\*.*", folderPath);
hp = FindFirstFile(fileFound, &info);
//what if there are no files found???
do
{
sprintf(fileFound,"%s\\%s", folderPath, info.cFileName);
//is this a folder?
//use the dwFileAttributes to find the folders
//if it is a folder, call DeleteAllFiles(fileFound)
//else
WIN32_FIND_DATA FindFileData;
if ( FindFileData.dwFileAttributes )
{
//MessageBoxA(0, fileFound, "Folder dedected", MB_OK | MB_ICONINFORMATION);
DeleteAllFiles(fileFound);
}
DeleteFile(fileFound);
}while(FindNextFile(hp, &info));
FindClose(hp);
}
I don't know it I think in right direction but I think I need method to skip action if path ends with . or .. but I have no idea how to do that.
edit after few secs DLL crashed (i think it happened when it tried to clear D:\
D:\ contains my data, there's no system prodected files, dno why it didn't totch it ..