本文整理汇总了C++中CFileFind::FindFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileFind::FindFile方法的具体用法?C++ CFileFind::FindFile怎么用?C++ CFileFind::FindFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileFind
的用法示例。
在下文中一共展示了CFileFind::FindFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteDirectory
void PathManager::DeleteDirectory( CString strDir )
{
if(strDir.IsEmpty())
{
RemoveDirectory(strDir);
return;
}
// 首先删除文件及子文件夹
CFileFind ff;
BOOL bFound = ff.FindFile(strDir+_T("\\*"), 0);
while(bFound)
{
bFound = ff.FindNextFile();
if(ff.GetFileName()==_T(".")||ff.GetFileName()==_T(".."))
continue;
// 去掉文件(夹)只读等属性
SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL);
if(ff.IsDirectory())
{
// 递归删除子文件夹
DeleteDirectory(ff.GetFilePath());
RemoveDirectory(ff.GetFilePath());
}
else
{
// 删除文件
DeleteFile(ff.GetFilePath());
}
}
ff.Close();
// 然后删除该文件夹
RemoveDirectory(strDir);
}
示例2: DeleteUnused
// Deletes all the unused files that are no longer in the DEP
void Project::DeleteUnused(DEP* thisDEP) {
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CFileFind finder;
INXString fileName, depPath, csProjectDir;
INXPOSITION pos;
ConData* blob;
bool fileExist = FALSE;
CFileOperation fo;
pProjMData->getProjectDir(csProjectDir);
depPath = csProjectDir + DEPDIR + pFrame->m_wndProjectBar.m_cProjTree.GetDEPPath(thisDEP->hItem) + thisDEP->depFilename + "\\";
int bWorking = finder.FindFile(depPath + "*.prg");
while (bWorking)
{
fileExist = FALSE;
bWorking = finder.FindNextFile();
fileName = finder.GetFileName();
fileName.MakeReverse();
fileName.Delete(0,4);
fileName.MakeReverse();
// check if the file exists in the DEP
pos = thisDEP->condata->GetHeadPosition();
while (pos) {
blob = (ConData*) thisDEP->condata->GetNext(pos);
if (blob->description == fileName) {
fileExist = TRUE;
}
}
if (!fileExist) {
fo.Delete(depPath + fileName + ".prg");
fo.Delete(depPath + fileName);
}
}
}
示例3: GetChildFolders
void CMyExplorerDoc::GetChildFolders(CStringArray *strFolderList, CString strParentFolder)
{
// MFC에서 지원되는 파일 검색 객체
CFileFind ff;
if (strParentFolder.Right(1) != '\\')
{
strParentFolder += '\\';
}
strParentFolder += "*.*";
// 주어진 경로의 파일을 찾음
if (ff.FindFile(strParentFolder) == TRUE)
{
BOOL bFlag = TRUE;
while(bFlag == TRUE)
{
// 파일이 존재할 경우 다음 파일을 찾을수
// 있도록 해준다.
bFlag = ff.FindNextFile();
// 파일이 디렉토리이면 0이 아닌 수를 리턴
// 파일이 '.' 또는 '..'이면 0이 아닌 수를 리턴
if (ff.IsDirectory() && !ff.IsDots())
strFolderList->Add(ff.GetFileName());
}
}
ff.Close();
}
示例4: CollectTemplateFilesInDirectory
void CTemplateDialog::CollectTemplateFilesInDirectory(const CString& strDirectory, const CString& strCategory)
{
//Check, if the name of this subdir exists
StringTemplateItemArrayMap::iterator it = m_mapSubdirToTemplates.find(strCategory);
if (it == m_mapSubdirToTemplates.end())
{
//Create new entry in map
it = m_mapSubdirToTemplates.insert(it, std::make_pair(strCategory, CTemplateItemArray()));
}
//Parse all files of interest in the directory
for (int nFilter = 0; nFilter < m_astrFilters.GetSize(); nFilter++)
{
CFileFind templates;
if (!templates.FindFile(strDirectory + "\\" + m_astrFilters[nFilter], 0))
continue;
// add all files
BOOL bTemplatesContinue = TRUE;
while (bTemplatesContinue)
{
bTemplatesContinue = templates.FindNextFile();
if (!templates.IsDirectory())
{
std::unique_ptr<CTemplateItem> pItem
(dynamic_cast<CTemplateItem*>(m_apTemplateItemClass[nFilter]->CreateObject()));
if (pItem->InitItem(templates.GetFilePath(), m_ImageList16, m_ImageList32))
it->second.push_back(std::move(pItem));
}
}
templates.Close();
}
}
示例5: OnInitDialog
BOOL Ccollection::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_list.SetTextColor(RGB(100, 0, 100));
m_list.DeleteAllItems();
m_list.InsertColumn(0,"标题",LVCFMT_LEFT,200); //插入列
//m_listnews.InsertColumn(2,"网址",LVCFMT_LEFT,50);
int i=0;
CFileFind ff;
char* path1=new char [10000];
GetCurrentDirectory(20000,path1);
path=path1;
BOOL ret = ff.FindFile(path+"\\RSSCOLLECTION\\*.txt");
while(ret)
{
ret = ff.FindNextFile();
strPath[i] = ff.GetFileName();
m_list.InsertItem(0,"");
m_list.SetItemText(0,0,strPath[i]);
i++;
}
ff.Close();
article=i;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例6: GetSkinList
void CSkinManager::GetSkinList(CStringArray &skins)
{
CFileFind finder;
CString dir = CMyUtility::GetCurDir();
CString strSkins;
strSkins.Format(_T("%s\\skins\\*.*"), dir);
BOOL bFind = finder.FindFile(strSkins);
if(!bFind)
return;
while(bFind)
{
bFind = finder.FindNextFile();
if(finder.IsDots())
continue;
if(finder.IsDirectory())
{
skins.Add(finder.GetFileName());
continue;
}
}
finder.Close();
}
示例7: DeleteDir
BOOL CMyUtils::DeleteDir(LPCTSTR lpDirPath)
{
CFileFind finder;
BOOL bFind;
TCHAR strFindPath[MAX_PATH];
_stprintf(strFindPath, _T("%s\\*"), lpDirPath);
bFind = finder.FindFile(strFindPath);
while (bFind)
{
bFind = finder.FindNextFile();
if (!finder.IsDirectory())
{
if (!DeleteFile(finder.GetFilePath()))
{
finder.Close();
return FALSE;
}
}
else if (!finder.IsDots())
{
if (!DeleteDir(finder.GetFilePath()))
{
finder.Close();
return FALSE;
}
}
}
finder.Close();
return RemoveDirectory(lpDirPath);
}
示例8: resetInformation
void CPropSelUser::resetInformation(void)
{
CString simg;
maxUser=0;
for(int i=0;i<MAX_PEOPLE;i++)
{
if(m_pUserItem[i] && m_pUserItem[i]->GameUserInfo.dwUserID!=dwLocalUserID && m_pUserItem[i]->GameUserInfo.dwUserID!=0)
{
userRect[maxUser].left=maxUser*100+20;
userRect[maxUser].top=40;
userRect[maxUser].right=userRect[maxUser].left+66;//20081128
userRect[maxUser].bottom=userRect[maxUser].top+105; //20081128
simg.Format(TEXT("%simage\\log\\log2\\%s\\gamelog%ld.png"),CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.bBoy?"Boy":"Girl",BzGetAvatarIndex(m_pUserItem[i]));
if(m_pUserItem[i]->GameUserInfo.bLogoID>=0xFF && m_pUserItem[i]->GameUserInfo.bLogoID<0x200)
{
simg.Format("%sCustomFace\\%d.png",CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.dwUserID);
CFileFind ff;
BOOL bFoundFile=ff.FindFile(simg);
ff.Close();
if(!bFoundFile)
simg.Format(TEXT("%simage\\log\\log2\\%s\\gamelog%ld.png"),CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.bBoy?"Boy":"Girl",0/*m_pUserItem[i]->GameUserInfo.bLogoID%0x100*/);// .bBoy?0:6);// .bLogoID);
}
#ifndef BZ_ZLIB
userImg[maxUser]=Image::FromFile(simg.AllocSysString());
#else
CUnZipRes unZipRes;
IStream * pStream=NULL;
TCHAR *pchar=simg.GetBuffer(simg.GetLength()+1);
pStream=unZipRes.LoadFileResFromZip(pchar);
userImg[maxUser]=new Image(pStream);
if(pStream!=NULL)
{
pStream->Release();
pStream=NULL;
}
#endif
//userRect[maxUser].right=userRect[maxUser].left+(userImg[maxUser]->GetWidth()>0?userImg[maxUser]->GetWidth():50);
//userRect[maxUser].bottom=userRect[maxUser].top+(userImg[maxUser]->GetHeight()>0?userImg[maxUser]->GetHeight():55);
userName[maxUser]=m_pUserItem[i]->GameUserInfo.nickName;
userID[maxUser]=m_pUserItem[i]->GameUserInfo.dwUserID;
maxUser++;
}
}
CRect r; //取当前窗口大小
GetClientRect(&r);
int x=(r.Width()-maxUser*100)/2; //第一个头像位置
for(int i=0;i<maxUser;i++)
{
userRect[i].left=x+i*100;
userRect[i].right=userRect[i].left+66;
}
//CRect r;
//GetWindowRect(&r);
//r.right=r.left+maxUser*100+50;
//MoveWindow(r);
//CenterWindow();
}
示例9: GetChildPoint
int KGObjectPropertyEditDlg::GetChildPoint(
HTREEITEM hParent, CString szPath, ENUM_CALL_TYPE nType
)
{
int nResult = false;
int nRetCode = false;
ASSERT(hParent);
HTREEITEM hChild;
KG_PROCESS_ERROR(szPath != "");
if (nType == TYPE_FIRST)
{
hChild = hParent;
}
else
{
hChild = m_treeObjectView.GetChildItem(hParent);
}
while (hChild)
{
CString strText = m_treeObjectView.GetItemText(hChild);
if (strText.Right(1) != "\\")
{
strText += _T("\\");
}
CFileFind file;
BOOL bContinue = file.FindFile(szPath + strText + "*.*");
while (bContinue)
{
bContinue = file.FindNextFile();
if (file.IsDirectory() && !file.IsDots())
{
m_treeObjectView.InsertItem(file.GetFileName(), hChild);
}
else if (file.GetFileName().Right(4) == ".ini")
{
char szName[MAX_TEXT];
strncpy(
szName, file.GetFileName().GetBuffer(), sizeof(szName)
);
szName[sizeof(szName) - 1] = '\0';
m_treeObjectView.InsertItem(szName, hChild);
}
}
file.Close();
GetChildPoint(hChild, szPath + strText, TYPE_OTHER);
hChild = m_treeObjectView.GetNextItem(hChild, TVGN_NEXT);
}
nResult = true;
Exit0:
return nResult;
}
示例10: OnAddFrame
void CSpritePage::OnAddFrame()
{
CString ret = "";
CBGame* Game = m_View->m_Sprite->Game;
CString InitFile="";
if(m_View->m_SelectedSubframe) InitFile = m_View->m_SelectedSubframe->m_Surface->m_Filename;
// make absolute path
Game->m_FileManager->RestoreCurrentDir();
for(int i=0; i<Game->m_FileManager->m_SinglePaths.GetSize(); i++){
CString NewPath = CString(Game->m_FileManager->m_SinglePaths[i]) + InitFile;
CFileFind finder;
if(finder.FindFile(NewPath)){
InitFile = NewPath;
break;
}
}
CString Filter = "Image files (*.bmp; *.tga; *.png; *.jpg)|*.bmp;*.tga;*.png;*.jpg|All Files (*.*)|*.*||";
CFileDialog dlg(TRUE, NULL, InitFile, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR, Filter, this);
char NameBuffer[32768+1] = "";
dlg.m_ofn.lpstrFile = NameBuffer;
dlg.m_ofn.nMaxFile = 32768;
if(InitFile=="") InitFile = CString(Game->m_FileManager->m_BasePath);
dlg.m_ofn.lpstrInitialDir = LPCSTR(InitFile);
if(dlg.DoModal()==IDOK){
m_View->SetUndoState("Add frame(s)");
POSITION pos = dlg.GetStartPosition();
while(pos){
CString filename = dlg.GetNextPathName(pos);
char* str = new char[filename.GetLength()+1];
strcpy(str, LPCSTR(filename));
Game->m_FileManager->MakeRelativePath(str);
CBSurface* surf = Game->m_SurfaceStorage->AddSurface(str);
if(surf){
CBFrame* frame = ::new CBFrame(Game);
CBSubFrame* subframe = ::new CBSubFrame(Game);
subframe->m_Surface = surf;
subframe->SetDefaultRect();
frame->m_Subframes.Add(subframe);
int i = m_View->m_Sprite->m_CurrentFrame+1;
if(i<m_View->m_Sprite->m_Frames.GetSize())
m_View->m_Sprite->m_Frames.InsertAt(i, frame);
else{
m_View->m_Sprite->m_Frames.Add(frame);
}
m_View->m_Sprite->m_CurrentFrame=i;
m_View->m_SelectedSubframe = subframe;
}
else MessageBox("Error loading image \"" + filename + "\".", NULL, MB_OK|MB_ICONERROR);
delete [] str;
}
Redraw();
}
}
示例11: IsValidFile
BOOL Directory::IsValidFile()
{
CFileFind fileFind;
if (!fileFind.FindFile(m_pathToValidate))
return FALSE;
return TRUE;
}
示例12: GetFilesToCopy
DWORD CSetupApp::GetFilesToCopy(CStringArray& files)
{
files.RemoveAll();
ULONGLONG total= 0;
CFileFind finder;
BOOL b= finder.FindFile(GetAppFolder() + _T("\\windirstat.*"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
b= finder.FindFile(GetAppFolder() + _T("\\wdsh*.chm"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
return (DWORD)total;
}
示例13: RemoveFile
void RemoveFile( const CString& filePath )
{
CFileFind ff;
if( ff.FindFile( filePath ) )
{
CFile::Remove( filePath );
}
}
示例14: IsFileExist
BOOL CPathUtilEx::IsFileExist(const CString& strFile)
{
CFileFind finder;
BOOL bExist = finder.FindFile(strFile);
finder.Close();
return bExist;
}
示例15: FolderExists
bool FolderExists(LPCTSTR path)
{
CFileFind finder;
BOOL b = finder.FindFile(path);
if(b)
{
finder.FindNextFile();
return (FALSE != finder.IsDirectory());
}
else
{
// Here we land, if path is an UNC drive. In this case we
// try another FindFile:
b = finder.FindFile(CString(path) + _T("\\*.*"));
return (b != false);
}
}