修改我的代碼刪除目錄,但我仍然有同樣的問題,該文件將不會刪除和目錄仍沒有刪除,我需要幫助我需要幫助使用DeleteDirectory和的DeleteFile API函數
#include<stdio.h>
#include<Windows.h>
#include<tchar.h>
void Delete(WIN32_FIND_DATA x);
int main(int argc , char*argv[])
{
WIN32_FIND_DATA x , d;
HANDLE f = FindFirstFile(L"d:\\Text\\*.*" , &x);
if(f == INVALID_HANDLE_VALUE)
{
printf("Serach faild\n");
return 0;
}
Delete(x);
while(FindNextFile(f , &x))
Delete(x);
FindClose(f);
printf("Now I'm going to delete the Directory\n");
if(RemoveDirectory(L"d:\\Text"))
printf("Successed\n");
else
printf("Did not\n");
}
void Delete(WIN32_FIND_DATA x)
{
if((x.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
{
_tprintf(L"The first File name is %s\n" , x.cFileName);
printf("I'm going To delete The File\n");
if(DeleteFile(L"d:\\Text\\x.cFileName"))
printf("File Deleted\n");
else printf("False\n");
}
else
_tprintf(L"The Directory name is %s\n" , x.cFileName);
}
我不能在這個代碼查找問題,我寫了我什麼都知道,任何人都可以編輯的工作,並感謝大家
你的意思是DeleteFile而不是Delete? shfileoperation API可以在一次調用中完成所有這些操作 – 2012-04-01 12:01:25
但是How?你可以幫我嗎? – Lara 2012-04-01 12:19:58