`

CFileDialog多选文件时的最大数量

阅读更多

system("explorer d:\我的文件夹");

 

GetDlgItemText(IDC_FILEHEAD,fileh);
 fileheadlength=atoi(fileh);

 XYZ_OXYGEN=3;
 TCHAR *pszFile = new TCHAR[MAX_PATH*MAX_PATH*MAX_PATH];
 memset(pszFile,0,sizeof(TCHAR)*MAX_PATH*MAX_PATH*MAX_PATH);

 CFileDialog   Dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,_T("oxy Files(*.dat)|*.dat| All Files(*.*)|*.*||"));
 Dlg.m_ofn.nMaxFile=MAX_PATH*MAX_PATH*MAX_PATH;

 Dlg.m_ofn.lpstrFile=pszFile;//lpstrFile必须和nMaxFile配对出现?
// int openok=Dlg.DoModal();

 if(Dlg.DoModal()==IDOK)
 {
  filename = Dlg.GetPathName();

  POSITION   pos  = Dlg.GetStartPosition();

  while(pos)
  {
   CString  szFileName = Dlg.GetNextPathName(pos);
   CFile file;

   if(file.Open(szFileName, CFile::modeRead))
   {
    //得到文件长度,从而确定读取缓存的大小  
    filesize +=(file.GetLength()-fileheadlength);
   }
   file.Close();
  }
 

    pBuf=new BYTE[filesize];
    pos  = Dlg.GetStartPosition();
    int ipbuf=0;
  while(pos)
  {
   CString  szFileName = Dlg.GetNextPathName(pos);
   CFile file;

   if(file.Open(szFileName, CFile::modeRead))
   {
    //得到文件长度,从而确定读取缓存的大小  
    everfilesize =(file.GetLength()-fileheadlength);
    file.Seek(fileheadlength,CFile::begin);
    file.Read(pBuf+ipbuf*everfilesize,everfilesize);
    ipbuf++;
   }
   file.Close();
  }

 }

 else
 {
  MessageBox("打开文件失败!",NULL);
  /*CString messge;
  messge.Format("%s","打开文件失败!");
  SetWindowText(messge);*/
 }

 delete [] pszFile;
 pszFile=NULL;

 // TODO: 在此添加控件通知处理程序代码

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics