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;
}
}
}
}
}
}