再次询问CFileDialog类的问题,怎么样多个选中文件,并且把经过过滤之后的文件放到数组里? 就是能支持多个选中文件,并且只要选中到路径,把当前的路径取出来。把它赋值到数组里。紧急等待中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下这段代码希望对你有帮助 CFileDialog dlg( TRUE, NULL, NULL, OFN_ALLOWMULTISELECT, NULL, NULL ); DWORD MAXFILE = 2562; //2562 is the max dlg.m_ofn.nMaxFile = MAXFILE; char* pc = new char[MAXFILE]; dlg.m_ofn.lpstrFile = pc; dlg.m_ofn.lpstrFile[0] = NULL; int iReturn = dlg.DoModal(); if(iReturn == IDOK) { int nCount = 0; POSITION pos = dlg.GetStartPosition(); while (pos != NULL) { Cstring tmp = dlg.GetNextPathName(pos); Cstring fn = dlg.GetPathName(); long l = fn.GetLength(); long I = tmp.GetLength(); fn = tmp.Right(I - l - 1); char * szbuf; Cfile* pFile = NULL; Cfile* pFile1 = NULL; pFile = new Cfile(_T(tmp),Cfile::modeRead | Cfile::shareDenyNone); fn = "c:\\" + fn; pFile1 = new Cfile(_T(fn),Cfile::modeWrite | Cfile::modeCreate); ULONGLONG dwLength = pFile->GetLength(); szbuf = new char[dwLength];pFile->Read(szbuf,dwLength);pFile1->Write(szbuf,dwLength); if (pFile != NULL) { pFile->Close(); delete pFile; }if (pFile1 != NULL) { pFile1->Close(); delete pFile1; } nCount++; } Cstring str; str.Format("Successfully opened %d files\n", nCount); AfxMessageBox(str); } else if(iReturn == IDCANCEL) AfxMessageBox("Cancel");delete pc; 透明richedit DEBUG 与 _DEBUG 宏的区别与联系 数据库连接问题(火急) 如何在程序打开office的快捷方式? 用Object ARX怎么创建一个可停靠在AutoCAD的对话条?如何使用ARX的工具条? VC中基础类型的疑惑, 比如char和CHAR ,long和LONG 等 如何动态调整控件在浏览器中的现实尺寸 CByteArray的奇怪问题 用DAO还是ADO?如何选择? 怎样把LPCTSTR的数据转换成CString的数据啊?! 文件异常的解决,各位大虾快来帮帮小弟吧 我现在有几个类想封装成lib
CFileDialog dlg( TRUE, NULL, NULL, OFN_ALLOWMULTISELECT, NULL, NULL );
DWORD MAXFILE = 2562; //2562 is the max
dlg.m_ofn.nMaxFile = MAXFILE;
char* pc = new char[MAXFILE];
dlg.m_ofn.lpstrFile = pc;
dlg.m_ofn.lpstrFile[0] = NULL; int iReturn = dlg.DoModal();
if(iReturn == IDOK)
{
int nCount = 0;
POSITION pos = dlg.GetStartPosition();
while (pos != NULL)
{
Cstring tmp = dlg.GetNextPathName(pos);
Cstring fn = dlg.GetPathName();
long l = fn.GetLength();
long I = tmp.GetLength();
fn = tmp.Right(I - l - 1);
char * szbuf;
Cfile* pFile = NULL;
Cfile* pFile1 = NULL;
pFile = new Cfile(_T(tmp),Cfile::modeRead | Cfile::shareDenyNone);
fn = "c:\\" + fn;
pFile1 = new Cfile(_T(fn),Cfile::modeWrite | Cfile::modeCreate);
ULONGLONG dwLength = pFile->GetLength();
szbuf = new char[dwLength];
pFile->Read(szbuf,dwLength);
pFile1->Write(szbuf,dwLength);
if (pFile != NULL) {
pFile->Close();
delete pFile;
}
if (pFile1 != NULL) {
pFile1->Close();
delete pFile1;
} nCount++;
}
Cstring str;
str.Format("Successfully opened %d files\n", nCount);
AfxMessageBox(str);
}
else if(iReturn == IDCANCEL)
AfxMessageBox("Cancel");
delete pc;