如何用“打开”文件对话框选择多个目录? 已经实现了选择多个文件,但是我还想选择目录,怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有办法用默认的文件对话框选择目录。单选目录: char buffer[MAX_PATH]; BROWSEINFO m_pbi ; ::ZeroMemory(&m_pbi, sizeof(BROWSEINFO)); m_pbi.hwndOwner = GetSafeHwnd(); m_pbi.pszDisplayName = buffer; m_pbi.lpszTitle = ""; m_pbi.ulFlags = BIF_RETURNONLYFSDIRS; ITEMIDLIST *idl = SHBrowseForFolder(&m_pbi); if (idl) { SHGetPathFromIDList (idl, buffer); } 多选目录要自己做。 我估计也是。现在正在自己做一个list,显示某一目录下的文件和子目录。顺便问一句,如和判断一个全路径到底是目录还是文件? GetFileAttributes() & FILE_ATTIRBUTE_DIRECTORY // directory CFileFind::IsDirectoryMSDN中的例子:#include <afx.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:"));} unhandled exception是什么问题 DHTML界面开发需要了解那些内容? 关于写文件时突然断电 有个关于《深入浅出MFC》一个小程序设计的问题 有点小疑问 关于SQL两个值的比对! access连接两个程序 VC菜鸟的困惑 ODBC中无法绑定日期字段 在系统钩子里怎么实现TIMER 关于句柄的一个很弱智的问题! 在多文档程序中如何动态的获取主框架窗口客户区的大小? 怪事,使用VS.net开发MFC程序遇到的怪事
char buffer[MAX_PATH];
BROWSEINFO m_pbi ; ::ZeroMemory(&m_pbi, sizeof(BROWSEINFO));
m_pbi.hwndOwner = GetSafeHwnd();
m_pbi.pszDisplayName = buffer;
m_pbi.lpszTitle = "";
m_pbi.ulFlags = BIF_RETURNONLYFSDIRS; ITEMIDLIST *idl = SHBrowseForFolder(&m_pbi);
if (idl)
{
SHGetPathFromIDList (idl, buffer);
} 多选目录要自己做。
现在正在自己做一个list,显示某一目录下的文件和子目录。
顺便问一句,如和判断一个全路径到底是目录还是文件?
#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:"));
}