Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFindFile?

CFindFile?

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Can I use CFileFind to search for a specific file on my computer? I've seen that the class has to do with the CGopherFileFind and CFtpFileFind. So I guess it's perhaps impossible? I've tried this but nothing appears: void CFopiacjeDlg::OnButton1() { CFileFind finder; BOOL bWorking = finder.FindFile("Fcc32.exe"); while (bWorking) { bWorking = finder.FindNextFile(); AfxMessageBox(finder.GetFilePath()); } }

    R 1 Reply Last reply
    0
    • L Lost User

      Can I use CFileFind to search for a specific file on my computer? I've seen that the class has to do with the CGopherFileFind and CFtpFileFind. So I guess it's perhaps impossible? I've tried this but nothing appears: void CFopiacjeDlg::OnButton1() { CFileFind finder; BOOL bWorking = finder.FindFile("Fcc32.exe"); while (bWorking) { bWorking = finder.FindNextFile(); AfxMessageBox(finder.GetFilePath()); } }

      R Offline
      R Offline
      Rassman
      wrote on last edited by
      #2

      Findfile like that is only searching your current directory. (doth it search the PATH too? I can't remember.). But it isn't going to search your entire drive as you would want it to. I use findfile in a self recursive function (it calls itself). Like this, If you don't want the tree just chop those bits out. This is a version that fills a tree with directories. void CExIncView::FillDirTree() { char DRIVES[33]; DWORD DriveNumbers; DWORD j; int k,Image,ImageSelected; CString lString; HTREEITEM ParentList[33]; unsigned lDriveType; m_Messages = " "; UpdateData(FALSE); //For each drive collect all directories DriveNumbers = GetLogicalDrives(); j=1; for(j=1,k=0;k<32;k++,j*=2) { if( DriveNumbers & j ) { DRIVES[k] = 'A' + k; } else { DRIVES[k] = ' '; } } //TEMP Put drives into tree for(k=0;k<32;k++) { if( DRIVES[k] != ' ') { lString.Format("%c:",DRIVES[k]); lDriveType = GetDriveType(lString); switch(lDriveType) { case DRIVE_UNKNOWN ://The drive type cannot be determined. Image = 2; ImageSelected = 3; break; case DRIVE_NO_ROOT_DIR ://The root directory does not exist. Image = 2; ImageSelected = 3; break; case DRIVE_REMOVABLE ://The disk can be removed from the drive. Image = 0; ImageSelected = 1; break; case DRIVE_FIXED ://The disk cannot be removed from the drive. Image = 2; ImageSelected = 3; break; case DRIVE_REMOTE ://The drive is a remote (network) drive. Image = 2; ImageSelected = 3; break; case DRIVE_CDROM ://The drive is a CD-ROM drive. Image = 4; ImageSelected = 5; break; case DRIVE_RAMDISK ://The drive is a RAM disk. Image = 2; ImageSelected = 3; break; default: Image = 2; ImageSelected = 3; break; } //ParentList[k] = m_pDirTree.InsertItem(lString,TVI_ROOT,TVI_SORT); ParentList[k] = m_pDirTree.InsertItem(lString,Image,ImageSelected,TVI_ROOT,TVI_LAST); m_pDirTree.SetItemData( ParentList[k], (DWORD) 50 ); } else { ParentList[k] = NULL; } } //For each parent traverse directory tree for(k=0;k<32;k++) { if(ParentList[k] != NULL) { lString.Format("%c:",DRIVES[k]); SearchDir(lString,ParentList[k]); } } } SearchDir is the self recursive function. void CExIncView::SearchDir(CString sPath) { CString sFind,sTemp; CString sBase,sBase2; int Done; WIN32_FIND_DATA lpFindFileData; HANDLE Search

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups