Windows Remove Folder All Folders and File Codes

 1 bool DeleteFolderAll(LPCTSTR pSrcPath)

2 {
3 if(pSrcPath == NULL)
4 return false;
5
6 wchar_t pwcPath[MAX_PATH];
7 wcscpy(pwcPath, pSrcPath);
8 int ilen = wcslen(pwcPath);
9
10 if (pwcPath[ilen-1] == L'\< span style="color: #800000;">')
11 {
12 pwcPath[ilen-1] = 0;
13 }
14
15
16 wchar_t wcPath[MAX_PATH] = {0};
17 wcscpy(wcPath,pwcPath);
18 wcscat(wcPath,_T("\*.*")) ;
19 WIN32_FIND_DATA FindFileData;
20 ZeroMemory(&FindFileData,sizeof(WIN32_FIND_DATA));
21
22 HANDLE hFindFile = FindFirstFile(wcPath,&FindFileData);
23
24 if(hFindFile == INVALID_HANDLE_VALUE)
25 return false;
26
27 BOOL bContinue = true;
28
29 while (bContinue != false)
30 {
31 //bIsDots is true means yes. or..
32 bool bIsDots = (wcscmp(FindFileData.cFileName,_T(< span style="color: #800000;">"." )) == 0 || wcscmp(FindFileData.cFileName,_T("..")) == 0 );
33 if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && bIsDots == false)
34 {
35 //is a directory, then enter the directory
36 wcscpy(wcPath,pwcPath);
37 wcscat(wcPath,_T("\"));
38 wcscat(wcPath,FindFileData.cFileName);
39 DeleteFolderAll(wcPath);
40 //Find the next file
41 bContinue = FindNextFile(hFindFile,&FindFileData);
42 continue;
43 }
44
45 if (bIsDots == false)
46 {
47 //is the file deletion
48 wcscpy(wcPath,pwcPath);
49 wcscat(wcPath,_T("\"));
50 wcscat(wcPath,FindFileData.cFileName);
51 DeleteFile(wcPath);
52 }
53 //Find the next file
54 bContinue = FindNextFile(hFindFile,&FindFileData);
55
56 }
57
58 FindClose(hFindFile);
59
60 //Delete empty directory
61 RemoveDirectory(pwcPath);
62 return true;
63 }

 1 bool DeleteFolderAll(LPCTSTR pSrcPath)

2 {
3 if(pSrcPath == NULL)
4 return false;
5
6 wchar_t pwcPath[MAX_PATH];
7 wcscpy(pwcPath, pSrcPath);
8 int ilen = wcslen(pwcPath);
9
10 if (pwcPath[ilen-1] == L'\< span style="color: #800000;">')
11 {
12 pwcPath[ilen-1] = 0;
13 }
14
15
16 wchar_t wcPath[MAX_PATH] = {0};
17 wcscpy(wcPath,pwcPath);
18 wcscat(wcPath,_T("\*.*")) ;
19 WIN32_FIND_DATA FindFileData;
20 ZeroMemory(&FindFileData,sizeof(WIN32_FIND_DATA));
21
22 HANDLE hFindFile = FindFirstFile(wcPath,&FindFileData);
23
24 if(hFindFile == INVALID_HANDLE_VALUE)
25 return false;
26
27 BOOL bContinue = true;
28
29 while (bContinue != false)
30 {
31 //bIsDots is true means yes. or..
32 bool bIsDots = (wcscmp(FindFileData.cFileName,_T(< span style="color: #800000;">"." )) == 0 || wcscmp(FindFileData.cFileName,_T("..")) == 0 );
33 if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && bIsDots == false)
34 {
35 //is a directory, then enter the directory
36 wcscpy(wcPath,pwcPath);
37 wcscat(wcPath,_T("\"));
38 wcscat(wcPath,FindFileData.cFileName);
39 DeleteFolderAll(wcPath);
40 //Find the next file
41 bContinue = FindNextFile(hFindFile,&FindFileData);
42 continue;
43 }
44
45 if (bIsDots == false)
46 {
47 //is the file deletion
48 wcscpy(wcPath,pwcPath);
49 wcscat(wcPath,_T("\"));
50 wcscat(wcPath,FindFileData.cFileName);
51 DeleteFile(wcPath);
52 }
53 //Find the next file
54 bContinue = FindNextFile(hFindFile,&FindFileData);
55
56 }
57
58 FindClose(hFindFile);
59
60 //Delete empty directory
61 RemoveDirectory(pwcPath);
62 return true;
63 }

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5597 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.