autofindanddelete3
所属分类:状态条
开发工具:Visual C++
文件大小:13KB
下载次数:17
上传日期:2006-05-12 19:08:25
上 传 者:
demowolf
说明: VC产生的临时文件有时真的很烦人!当你编译一个程序,突然系统弹出一个对话框:“D盘已经没有足够的空间~~~~~~~~~请问需要进行磁盘清理吗”,而它只能清掉了Nkb的的东东,你有什么理由不自己写一个专门清理VC垃圾的小工具呢?隔一段时间运行一次,彻底清除指定类型的垃圾文件:干干净净,中国人,奇强!
很明显,这个程序的核心代码肯定是一个有通配符的功能的递归查找文件的函数。我的想法是先查找给定目录下的所有符合条件的文件,再递归查找下级文件夹下所有符合条件的文件。为了保证其封闭性,我用了一个CStringList&变量来保存搜索结果。如果您有好的建议,请给我发邮件。
(the temporary files sometimes really annoying! When you compile a program, suddenly a pop-up dialog box system : "D was not enough space ~~~~~~~~~ Will the need for disk clean up?" and it can only Nkb the tune of the price. what is your reason for not writing their own specialized cleaning up a small VC refuse tool? Periodically running a completely remove specified types of waste paper : clean, Chinese, Ever! Obviously, the core of this procedure code is certainly a wildcard recursive function of the document search functions. My idea is to find a given directory of all eligible document, then you lower recursive folder all eligible document. To ensure its closure, I spent a CStringList)
文件列表:
自动查找并删除VC生成的临时文件\DelTemp.h (1335, 2004-07-26)
自动查找并删除VC生成的临时文件\DelTempDlg.h (1643, 2004-08-31)
自动查找并删除VC生成的临时文件\resource.h (814, 2004-08-30)
自动查找并删除VC生成的临时文件\StdAfx.h (999, 2004-07-26)
自动查找并删除VC生成的临时文件\DelTemp.cpp (2044, 2004-07-26)
自动查找并删除VC生成的临时文件\DelTempDlg.cpp (7653, 2004-09-02)
自动查找并删除VC生成的临时文件\StdAfx.cpp (209, 2004-07-26)
自动查找并删除VC生成的临时文件\res\DelTemp.ico (1078, 2004-07-26)
自动查找并删除VC生成的临时文件\res\DelTemp.rc2 (399, 2004-07-26)
自动查找并删除VC生成的临时文件\res (0, 2004-07-26)
自动查找并删除VC生成的临时文件\DelTemp.dsp (4182, 2004-08-30)
自动查找并删除VC生成的临时文件\DelTemp.dsw (539, 2004-07-26)
自动查找并删除VC生成的临时文件\DelTemp.rc (6496, 2004-08-31)
自动查找并删除VC生成的临时文件 (0, 2005-02-18)
自动查找并删除VC生成的临时文件
作者:邓子国
关键字:临时文件 通配符 递归 查找文件 文件夹选择对话框 INI文件
VC产生的临时文件有时真的很烦人!当你编译一个程序,突然系统弹出一个对话框:“D盘已经没有足够的空间~~~~~~~~~请问需要进行磁盘清理吗”,而它只能清掉了Nkb的的东东,你有什么理由不自己写一个专门清理VC垃圾的小工具呢?隔一段时间运行一次,彻底清除指定类型的垃圾文件:干干净净,中国人,奇强!
很明显,这个程序的核心代码肯定是一个有通配符的功能的递归查找文件的函数。我的想法是先查找给定目录下的所有符合条件的文件,再递归查找下级文件夹下所有符合条件的文件。为了保证其封闭性,我用了一个CStringList&变量来保存搜索结果。如果您有好的建议,请给我发邮件。下面是代码:
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;
}
另外,程序中还用到了SHBrowseForFolder、SHGetPathFromIDList两个API函数来打开文件夹选择的对话框,GetProvateProfileInt、Get(/Write)PrivateProfileString、WritePrivateProfileSection等函数以方便用户自定义文件类型。因为程序比较简单,里面的一些错误信息显示也就没有单独抽象出来。不提倡读者这样写,呵呵。
转载请注明来源:
开源盛世-源代码下载网
http://www.vscodes.com
近期下载者:
相关文件:
收藏者: