Solved

File Access Times, File Handles

Posted on 1998-10-24
6
184 Views
Last Modified: 2013-11-20
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
Comment
Question by:bazzalar
[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
  • 3
  • 3
6 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323798
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
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1323799
The file handle is in the m_hFile member of CFile.

B ekiM
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323800
Isn't my "comment" more thorough than your "answer?"
0
Independent Software Vendors: 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!

 
LVL 11

Expert Comment

by:mikeblas
ID: 1323801
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323802
>> 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
 
LVL 11

Expert Comment

by:mikeblas
ID: 1323803
Actually, it's just a typo:

ExpertsExchange
ExpertSexchange

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

B ekiM
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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

728 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