Link to home
Start Free TrialLog in
Avatar of bazzalar
bazzalar

asked on

File Access Times, File Handles

I am writing a function to find the last write and last access times of a file (supplied with the path of the file (as a CString object). I opened the file with CFile.Open and I went to use GetFileTime to discover the times. However I can't work out how to find what the file handle is so that I can input it as the first argument. for GetFileHandle.

Does anyone habe any suggestions please?
Avatar of thresher_shark
thresher_shark

Since you are using MFC, you could use the CFile::GetStatus member function.  Here is an example:

CFile file;
file.Open ("yourfile.txt", CFile::modeReadWrite);

CFileStatus status_struct; // Status structure.
file.GetStatus (status_struct);


// End sample
At this point, you can access the fields of the status_struct structure.  The structure contains:

CTime m_ctime   The date and time the file was created.
CTime m_mtime   The date and time the file was last modified.
CTime m_atime   The date and time the file was last accessed for reading.
LONG m_size   The logical size of the file in bytes, as reported by the DIR command.
BYTE m_attribute   The attribute byte of the file.
char m_szFullName[_MAX_PATH]   The absolute filename in the Windows character set.

If you have any additional questions, please feel free to ask.  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Isn't my "comment" more thorough than your "answer?"
My answer answered the question it seems like he meant to ask. (There's no function named GetFileHandle(), but there is one named GetFileTime().) But it looks like your comment talked about a different way to get the job done than what bazzalar asked about.

Who knows what he really wants?

Since people tend to ask such painfully inspecific questions, it's a fundamental problem not only with Expert Sexchange, but with every question that anyone asks. Do you need to answer the question they're asking directly, or do you need to try to guess about the issue you believe they're _Really_ thinking of?

Anyway, it's not my doing that you didn't submit your response as an answer. Is it?

B ekiM


>> Since people tend to ask such painfully inspecific questions...
Yes, that is true, and it's unfortunate.

>> Expert Sexchange
Good anagram!

>> Anyway, it's not my doing that you didn't submit your
>> response as an answer. Is it?
No no, of course not.  I really should answer things for often when I think I know the answer, that seems to be the accepted practice.
Actually, it's just a typo:

ExpertsExchange
ExpertSexchange

It's why the URL has a hyphen, I guess.

B ekiM