Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CFileFind doesn't find System Directory !!!

Posted on 1999-01-05
3
Medium Priority
?
440 Views
Last Modified: 2013-11-20
This quite short code returns false with GetlastErorr = 18 (no more file). I don't understand what I'm doing wrong.

CFileFind            theFileFinder;
BOOL            result1, result2;

result1 = theFileFinder.FindFile("C:\\WINNT\\system32");
if (result1)
   result2 = theFileFinder.FindNextFile();

>>> My goal is to call GetCreationTime after this to get the system directory creation date (of course I won't use the constant string but I'll use "GetSystemDirectory").

Thanks for any hint.
0
Comment
Question by:SergeDePauw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
nil_dib earned 300 total points
ID: 1327219
You did nothing wrong!
FindNextFile finds the next file from A PREVIOUS call to
FindFile. You have only ONE directory which is called "C:\\WINNT\\system32",
so FindNextFile must return false because no more directorys with this name exist!
If you write FindFile("*.*") then FindNextFile will return true because there are more files than match "*.*".
0
 

Author Comment

by:SergeDePauw
ID: 1327220
That's maybe correct but a call to GetCreationTime fails if I don't call FindNextFile (as stated in the doc.).

Does that mean it is not possible to access a file directly but that I need to find the "previous" file first and then use "FindNextFile" to get the one I need. That's quite ridiculous to me.

So I found another way. I use the Win32 function "FindFIrstFile" and it works much better than the MFC object.

Thank you for your time.
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1327221
Ok,
I see thats really confusing ...
Another way is to use GetFileAttributesEx:
WIN32_FILE_ATTRIBUTE_DATA g;
GET_FILEEX_INFO_LEVELS h;
GetFileAttributesEx("C:\\winnt\\system32", h, (void*)&g);

or GetFileInformationByHandle:
BY_HANDLE_FILE_INFORMATION info;
HANDLE hFile = CreateFile ( ("C:\\winnt\\system32",
            GENERIC_READ,
            0,
            NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_SYSTEM,
            NULL );
GetFileInformationByHandle( hFile, &info );

regards nil_dib
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question