Solved

File Access Times, File Handles

Posted on 1998-10-24
6
179 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
Industry Leaders: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
method notes when mouse over in eclipse 5 90
if loop in java 3 163
move a line in eclipse 3 109
Excel file not created as expected 7 93
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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