• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

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?
0
bazzalar
Asked:
bazzalar
  • 3
  • 3
1 Solution
 
thresher_sharkCommented:
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!
0
 
mikeblasCommented:
The file handle is in the m_hFile member of CFile.

B ekiM
0
 
thresher_sharkCommented:
Isn't my "comment" more thorough than your "answer?"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mikeblasCommented:
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


0
 
thresher_sharkCommented:
>> 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.
0
 
mikeblasCommented:
Actually, it's just a typo:

ExpertsExchange
ExpertSexchange

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

B ekiM
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now