By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,671 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,671 IT Pros & Developers. It's quick & easy.

How can I get the date of a file?

P: n/a
I would like to get the last run date of a file called "scale.txt". How
would I do that?
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Keith

Take a look at the System.IO.FileInfo object, this should give you the last
access time and last write time information.

HTH

Glenn

"Keith Smith" <ke*********@verizon.net> wrote in message
news:dQiXd.70279$uc.12278@trnddc08...
I would like to get the last run date of a file called "scale.txt". How
would I do that?

Nov 16 '05 #2

P: n/a
You could use FileInfo

FileInfo fi = new FileInfo("scale.txt");
this.textBox1.Text = fi.LastAccessTime.ToString();

that should get you a string looking like this: "2005-03-
08 14:23:47"

don't forget to include System.IO

/Johan
Nov 16 '05 #3

P: n/a

Keith:

using System.IO
FileInfo MyFile as new FileInfo("c:\\scale.txt") ;

string Staccess = MyFile.LastAccessTime.ToString() ;

string Strcreation = MyFile.creationTime.ToString();

string Strmodified = MyFile.modifiedTime.ToString();

Hope this helps

Yonas

"Keith Smith" <ke*********@verizon.net> wrote in message
news:dQiXd.70279$uc.12278@trnddc08...
I would like to get the last run date of a file called "scale.txt". How
would I do that?

Nov 16 '05 #4

P: n/a
> using System.IO
FileInfo MyFile as new FileInfo("c:\\scale.txt") ;

string Staccess = MyFile.LastAccessTime.ToString() ;

string Strcreation = MyFile.creationTime.ToString();

string Strmodified = MyFile.modifiedTime.ToString();

Hope this helps

Yonas


Yonas, thanks for your clear answer.
Nov 16 '05 #5

P: n/a
For those interested....I had to make a small correction on the second
line...
using System.IO
FileInfo MyFile = new FileInfo("c:\\scale.txt") ;

string Staccess = MyFile.LastAccessTime.ToString() ;

string Strcreation = MyFile.creationTime.ToString();

string Strmodified = MyFile.modifiedTime.ToString();

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.