Automatically search for and delete temporary files generated by VC

Source: Internet
Author: User
Keywords

Temporary File wildcard recursive search file folder selection dialog box INI File

Body

Temporary files generated by VC are sometimes really annoying! When you compile a program, a dialog box pops up in the system: "disk D does not have enough space. Do you need to clear the disk?", but it can only clear nkb, do you have any reason not to write a small tool dedicated to clearing VC junk? Run it once every other time to completely clear the specified type of junk files: clean, Chinese, qiqiang!

Obviously, the core code of this program must be a recursive file search function with wildcards. My idea is to first find all the files that meet the conditions under the given directory, and then recursively find all the files that meet the conditions under the lower-level folder. To ensure its closeness, I used a cstringlist & variable to save the search results. If you have good suggestions, please send me an email. The following code is used:

CStringList& CDelTempDlg::SearchFile(CString strFileName,                                      CString strPath,                                      CStringList &listFileName) { char szFullPathName[MAX_PATH]; /*static*/ WIN32_FIND_DATA findData; SetCurrentDirectory(strPath); HANDLE hFindHandle = FindFirstFile(strFileName, &findData); if ((hFindHandle != INVALID_HANDLE_VALUE)) { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { GetFullPathName(findData.cFileName,                 MAX_PATH,                 szFullPathName,                 NULL);                 listFileName.AddTail(szFullPathName); } while (FindNextFile(hFindHandle, &findData) != 0) { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { GetFullPathName(findData.cFileName,                 MAX_PATH,                 szFullPathName,                 NULL);                 listFileName.AddTail(szFullPathName); } } FindClose(hFindHandle); } hFindHandle = FindFirstFile(\"*\", &findData); if ((hFindHandle != INVALID_HANDLE_VALUE)) { if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (findData.cFileName[0] != \''.\'') { SearchFile(strFileName,            findData.cFileName,            listFileName);            SetCurrentDirectory(\"..\"); } }while (FindNextFile(hFindHandle, &findData) != 0) { if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (findData.cFileName[0] != \''.\'') { SearchFile(strFileName,            findData.cFileName,            listFileName);            SetCurrentDirectory(\"..\"); } } } FindClose(hFindHandle); } return listFileName; }   

In addition, two API functions shbrowseforfolder and shgetpathfromidlist are used in the program to open the folder selection dialog box. functions such as getprovateprofileint, get (/write) privateprofilestring, and writeprivateprofilesection are used to help. Because the program is relatively simple, some error information is not abstracted separately. We do not recommend that Readers write like this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.