列出全部文件

 CString strFind = m_csFolderPath;
 strFind += "//*.*";
 // 指定フォルダーのファイルを検索する
 CFileFind finder;
 BOOL bWorking = finder.FindFile(strFind);
 //while(bWorking)
 //{
 // bWorking = finder.FindNextFile();
 // CString strFile = finder.GetFileName();
 // if((strFile == ".") || (strFile == ".."))
 // {
 //  continue;
 // }

 // CString strPath = m_csFolderPath + "//" + strFile;

 // int nPos = strFile.ReverseFind('.');
 // if(nPos != -1)
 // {
 //  CString csFileType = strFile.Mid(nPos+1);
 //  csFileType.MakeUpper();
 //  if(csFileType == _T("LNK"))  //リンクファイルであれば、保存する
 //  {
 //   if(m_nFileCount < pWinApp->m_nDNaviMaxShow)
 //   {
 //    m_strFileNameArray.Add(strPath);
 //    m_nFileCount++;
 //   }
 //   else
 //   {
 //    finder.Close();
 //    return;
 //   }
 //  }
 // }
 //}
 //方法を使う前に_accessを判断必要
 CString strFind = m_strPath;
 strFind += "//*.*";
 // 指定フォルダーのファイルを検索する
 CFileFind finder;
 BOOL bWorking = finder.FindFile( strFind );
 while(1){
  if (bWorking)
  {
   bWorking = finder.FindNextFile();
   CString strFile = finder.GetFileName();
   if ((strFile == ".") || (strFile == ".."))
   {
    continue;
   }
   CString strPath = m_strPath + "//" + strFile;
   if (finder.IsDirectory()){
    CFolderFile* pFolder = new CFolderFile(strPath);
    pFolder->GetFile();
    m_strFileNameArray.Append(pFolder->m_strFileNameArray);
    m_dwAllSize += pFolder->m_dwAllSize;
    delete pFolder;
   }else{
    m_strFileNameArray.Add(strPath);
    DWORD dwLen = (DWORD)finder.GetLength();
    m_dwAllSize += dwLen;
   }
  }else{
   if (GetLastError() == ERROR_MORE_DATA)
   {
    bWorking = finder.FindNextFile();    
   }else{
    break;
   }
  }
 }

//113Q 趙 削除する----------->
// while (bWorking){
//  bWorking = finder.FindNextFile();
//  CString strFile = finder.GetFileName();
//  if( (strFile == ".") || (strFile == "..") ){
//   continue;
//  }
MFCのバグ('能'や'表'、'ゾ'等、'/'や'/'のコードと下位バイトが同じになる文字がフォル
ダに使用されていると不正なパスとなる。例.C:/Temp/表/計算.xls → C:/Temp/表計算.xls)
回避コード -->
  CString strPath = finder.GetFilePath();
//  CString strPath = m_strPath + "//" + strFile;
//
//  if( finder.IsDirectory() ){
//   CFolderFile* pFolder = new CFolderFile( strPath );
//   pFolder->GetFile();
//   m_strFileNameArray.Append( pFolder->m_strFileNameArray );
//   m_dwAllSize += pFolder->m_dwAllSize;
//   delete pFolder;
//  }else{
//   m_strFileNameArray.Add( strPath );
//   DWORD dwLen = (DWORD)finder.GetLength();
//   m_dwAllSize += dwLen;
//  }
//  
// }
// finder.Close();

 int nRet = _access(szDNaviFolder, 0);
 if(nRet == -1)
 {
  return FALSE;
 }

 

 CImgLunchApp *pWinApp = (CImgLunchApp*)AfxGetApp();
 WIN32_FIND_DATAW fd;
 HANDLE hFind = INVALID_HANDLE_VALUE;
 USES_CONVERSION;
 CStringW strFind = A2W(m_csFolderPath);
 strFind += L"//*";
 hFind = ::FindFirstFileW(strFind, &fd);
 if (INVALID_HANDLE_VALUE != hFind)
 {
  while(::FindNextFileW(hFind, &fd) != 0){
   if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
   {
    CString strFile = W2A(fd.cFileName);
    CString strPath = m_csFolderPath + "//" + strFile;
    int nPos = strFile.ReverseFind('.');
    if(nPos != -1)
    {
     CString csFileType = strFile.Mid(nPos+1);
     csFileType.MakeUpper();
     if(csFileType == _T("LNK"))  //リンクファイルであれば、保存する
     {
      if(m_nFileCount < pWinApp->m_nDNaviMaxShow)
      {
       m_strFileNameArray.Add(strPath);
       m_nFileCount++;
      }
      else
      {
       return;
      }
     }
    }
   }
  }
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值