Is there a more efficient way to compare two files' LastWriteTime? 
Author Message
 Is there a more efficient way to compare two files' LastWriteTime?

At present, i use the following sentences to compare two files'
LastWriteTime:

// Begin of sentences
WIN32_FIND_DATA wfd;
HANDLE hFind;
CTime timeSrc, timeTgt;

hFind = FindFirstFile(strSrcFile, &wfd);
ASSERT(hFind == INVALID_HANDLE_VALUE);
timeSrc = wfd.ftLastWriteTime;
FindClose(hFind);

hFind = FindFirstFile(strTgtFile, &wfd);
ASSERT(hFind == INVALID_HANDLE_VALUE);
timeTgt = wfd.ftLastWriteTime;
FindClose(hFind);

if(timeTgt > timeSrc) {
    ...

Quote:
}

// End of sentences

My question is, is there a more efficient way to do so?

Thanks in advance,

--

Software Engineer
Shanghai Kehwa Software Development Ltd., Co.



Thu, 27 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?

Quote:
>hFind = FindFirstFile(strSrcFile, &wfd);
>ASSERT(hFind == INVALID_HANDLE_VALUE);
>timeSrc = wfd.ftLastWriteTime;
>FindClose(hFind);

You could use GetFileTime instead of FindFirstFile.

Dave
--
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Thu, 27 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?


Quote:
>At present, i use the following sentences to compare two files'
>LastWriteTime:
....

>My question is, is there a more efficient way to do so?

>Thanks in advance,

GetFileTime can retrieve times the file was created, last accessed,
and modified.

Steve
--
Steve Wolstenholme
Neural Network Applications for Windows
http://www.tropheus.demon.co.uk



Thu, 27 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?
Yes, call GetFileTime and then CompareFileTime


Thu, 27 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?
Probably not.  You can use GetFileTime(), but that only
works if you have an open file handle.  The runtime cost
of opening a file handle is probably significantly higher
than the runtime cost of calling FindFirstFile().  Of course,
if you already have a file handle open, then GetFileTime is
probably superior in efficiency...

Les


Quote:
> At present, i use the following sentences to compare two files'
> LastWriteTime:

> // Begin of sentences
> WIN32_FIND_DATA wfd;
> HANDLE hFind;
> CTime timeSrc, timeTgt;

> hFind = FindFirstFile(strSrcFile, &wfd);
> ASSERT(hFind == INVALID_HANDLE_VALUE);
> timeSrc = wfd.ftLastWriteTime;
> FindClose(hFind);

> hFind = FindFirstFile(strTgtFile, &wfd);
> ASSERT(hFind == INVALID_HANDLE_VALUE);
> timeTgt = wfd.ftLastWriteTime;
> FindClose(hFind);

> if(timeTgt > timeSrc) {
>     ...
> }
> // End of sentences

> My question is, is there a more efficient way to do so?

> Thanks in advance,

> --

> Software Engineer
> Shanghai Kehwa Software Development Ltd., Co.



Thu, 27 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?
Use GetFileAttributesEx(). It gives you the file times without opening the
file.
Works on NT 4.0+ or Win98+

Guillaume.

Quote:

>At present, i use the following sentences to compare two files'
>LastWriteTime:

>// Begin of sentences
>WIN32_FIND_DATA wfd;
>HANDLE hFind;
>CTime timeSrc, timeTgt;

>hFind = FindFirstFile(strSrcFile, &wfd);
>ASSERT(hFind == INVALID_HANDLE_VALUE);
>timeSrc = wfd.ftLastWriteTime;
>FindClose(hFind);

>hFind = FindFirstFile(strTgtFile, &wfd);
>ASSERT(hFind == INVALID_HANDLE_VALUE);
>timeTgt = wfd.ftLastWriteTime;
>FindClose(hFind);

>if(timeTgt > timeSrc) {
>    ...
>}
>// End of sentences

>My question is, is there a more efficient way to do so?

>Thanks in advance,

>--

>Software Engineer
>Shanghai Kehwa Software Development Ltd., Co.



Fri, 28 Jun 2002 03:00:00 GMT  
 Is there a more efficient way to compare two files' LastWriteTime?
Thanks a lot, that's just i want.


Quote:
> Use GetFileAttributesEx(). It gives you the file times without opening the
> file.
> Works on NT 4.0+ or Win98+

> Guillaume.



Fri, 28 Jun 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Is there a more efficient way to compare two files' LastWriteTime?

2. Compare two text files, write the difference to the third file

3. How to compare two huge file programically?

4. Compare two text files

5. Comparing two text files - problem

6. Help--need really fast search to compare two HUGE files of text records

7. Compare two files

8. Way to compare two files

9. How to compare two binary file?

10. Need to compare two binary files

11. Difference between two different ways of doing things

12. Comparing directories, the most efficient algorithm

 

 
Powered by phpBB® Forum Software