怎样获得搜索到文件的路径。 ?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 msdn的例子:#include <afxwin.h>#include <iostream>using namespace std;void Recurse(LPCTSTR pstr){ CFileFind finder; // build a string with wildcards CString strWildcard(pstr); strWildcard += _T("\\*.*"); // start working for files BOOL bWorking = finder.FindFile(strWildcard); while (bWorking) { bWorking = finder.FindNextFile(); // skip . and .. files; otherwise, we'd // recur infinitely! if (finder.IsDots()) continue; // if it's a directory, recursively search it if (finder.IsDirectory()) { CString str = finder.GetFilePath(); cout << (LPCTSTR) str << endl; Recurse(str); } } finder.Close();}void main(){ if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0)) cout << "panic!" << endl; else Recurse(_T("C:"));} CString str = finder.GetFilePath();重点就在这句 用access(filename, 0) == 0 可以從硬盤上找到文件名為filename 的文件是否存在。 自然也能找到路徑 求学习资料 ClistCtrl 怎样给项加图标 每一项根据属性的不同加不同的图标? 自己写的关闭其他程序的C++程序,请教哪儿出错了? 请问怎么把文件里的内容一次全部读出啊,马上揭贴 windowsxp,一个已经运行的应用程序能否接收另一个应用程序传递过来的字符参数,能不能即时接收 高分求 COM 原理与应用 的电子书 注意 不是附书源码 SDK如何实现动画效果? 声明methed,当返回是字符串的时候,应该怎么写? 为什么我安的vc里没有components and activex控件? 旧程序升级,问题? vc如何设置button控件的风格 在OnMouseMove中画点的问题
#include <afxwin.h>
#include <iostream>using namespace std;void Recurse(LPCTSTR pstr)
{
CFileFind finder; // build a string with wildcards
CString strWildcard(pstr);
strWildcard += _T("\\*.*"); // start working for files
BOOL bWorking = finder.FindFile(strWildcard); while (bWorking)
{
bWorking = finder.FindNextFile(); // skip . and .. files; otherwise, we'd
// recur infinitely! if (finder.IsDots())
continue; // if it's a directory, recursively search it if (finder.IsDirectory())
{
CString str = finder.GetFilePath();
cout << (LPCTSTR) str << endl;
Recurse(str);
}
} finder.Close();
}void main()
{
if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))
cout << "panic!" << endl;
else
Recurse(_T("C:"));
}
自然也能找到路徑