How can I get the date of a file?

  • Thread starter Thread starter Keith Smith
  • Start date Start date
K

Keith Smith

I would like to get the last run date of a file called "scale.txt". How
would I do that?
 
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
 
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
 
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
 
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.
 
Back
Top