#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    29
    Rep Power
    0

    CFileFind not working


    I have code that looks like this:

    Code:
    CFileFind strFinder;
    int foldersfound = 0;
    CString strFolder = "";
    
    BOOL bFindFile = strFinder.FindFile("*.sit");  
    if(TRUE==bFindFile) {
    	while (bFindFile) {     
    		bFindFile = strFinder.FindNextFile();          
    		foldersfound++;
    		strFolder = (LPCTSTR) strFinder.GetFileName();
    		strFolder = strFolder.Left(strFolder.GetLength()-4);
    	}
    }
    strFinder.Close();
    This works fine. However, later on I have code like this:

    Code:
    CString szDirpath="\\"+m_NowOpen+"\\*.usr";
    int daysfound = 0;
    bFindFile = strFinder.FindFile(szDirpath);  
    if(TRUE==bFindFile) {
    	while (bFindFile) {
    		bFindFile = strFinder.FindNextFile();
    		daysfound++;
    	}
    }
    strFinder.Close();
    This code DOES NOT work. daysfound is still set to 0 after the code executes, even though I _know_ there are .usr files in that directory. Does anyone see what's wrong?
    Last edited by rjahrman; August 26th, 2003 at 11:29 PM.
  2. #2
  3. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    does this string actually contain what you want (the files path)

    CString szDirpath="\\"+m_NowOpen+"\\*.usr";

    try using '.\\' rather than '\\' for a folder off the current folder
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    29
    Rep Power
    0
    Thanks!!!!!!! The dot did it.
  6. #4
  7. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    Ahhhh, the power of the dot!

    All hail the mighty DOT!




    (Glad to help)
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa

IMN logo majestic logo threadwatch logo seochat tools logo