Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to capture the date and time stamp of a file Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Files Operation
Language
Delphi 2.x
Views
132
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to capture the date and time stamp of a file

Answer:

Would you like to display a file's date and/or time stamp to your user? There isn't 
a single Delphi function that does this on its own. However, we can combine two 
functions to get the results we want. First, the FileGetDate function returns the 
DOS date-time stamp of the file specified by its handle, Fhandle. Then, the 
FileDateToDateTime function translates the integer into a TDateTime value. Finally, 
the DateTimeToStr procedure converts the TDateTime value into a string.


1   procedure TForm1.Button1
2   var
3     TheFileDate: string;
4     FHandle: integer;
5   begin
6     FHandle := FileOpen(YourFileName, 0);
7     try
8       TheFileDate := DateTimeToStr(FileDateToDateTime(FileGetDate(FHandle)));
9     finally
10      FileClose(FHandle);
11    end;
12  end;



Use formatting parameters DateTimeToStr to refine the output. Even if you don't have to display the time and date, you can use this technique to perform comparisons and calculations on file dates.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC