Solved

File Access Times, File Handles

Posted on 1998-10-24
6
165 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now