#include "iostream.h"??? //由于該博客系統發布是不能顯示正常,代碼如需調試,只需將改成""即可
#include "string.h"
#include "stdlib.h"
#include "time.h"
#include "math.h"
#include "windows.h"
#include "stdio.h"
#include "shellapi.h"
#include "fstream.h"
#include "string"
using namespace std;
void main()
{
? //清空特定文件夾中的所有文件
? char* a=".";
? char* b="";
? WIN32_FIND_DATA FileData,FileData_0;
? HANDLE hSearch,hSearch_0;
? BOOL fFinished=FALSE;
? hSearch=FindFirstFile("C:\\experiment\\results_stat\\*.*",&FileData);???? //輸入特定文件的絕對路徑名
? if(hSearch==INVALID_HANDLE_VALUE)
? {
??? printf("No?? files?? found.");
??? return;
? }
? while(!fFinished)
? {
??? if(FileData.cFileName[0]!=a[0]){
????? b=FileData.cFileName;
????? string addr=string("C:\\experiment\\results_stat\\")+string(b)+string("\\")+string("*.*");??? //輸入特定文件的絕對路徑名
????? hSearch_0=FindFirstFile(addr.c_str(),&FileData_0);
????? while(FindNextFile(hSearch_0,?? &FileData_0)){
??????? if(FileData_0.cFileName[0]!=a[0]){
????????? string addr_0=string("C:\\experiment\\results_stat\\")+string(b)+string("\\")+FileData_0.cFileName;??? //輸入特定文件的絕對路徑名
????????? DeleteFile(addr_0.c_str());????? //清空特定文件夾中的子文件夾中的所有文件
??????? }
????? }
??? }
??? if(!FindNextFile(hSearch,&FileData))
??? {
????? if(GetLastError()==ERROR_NO_MORE_FILES)
????? {
??????? fFinished=TRUE;
????? }
????? else
????? {
??????? printf("Couldn't?? find?? next?? file.");
??????? return;
????? }
??? }
? }
? FindClose(hSearch);
? FindClose(hSearch_0);
}
?