473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How can I get the date of a file?

I would like to get the last run date of a file called "scale.txt". How
would I do that?
Nov 16 '05 #1
5 18752
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
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

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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hank | last post by:
Hi, I was wondering what is a quick way to find the latest(last modified date) file from a directory. Should I use win32file.GetFileTime and compare PyTime? I don't want to create a PyHANDLE...
3
by: gogomei | last post by:
I have a text file like following and need to read out the names of each person. Since the only accurate info is there is a null line before starting a new name, I have written following code to...
4
by: KriZ | last post by:
Can any tell me how to read a File Property like the Title, Subject, Author.. I have tried using a file call "Interop.DSOleFile.dll", it works...but It is not Strong Named... I want something...
2
by: Robizzle | last post by:
Sorry, I must be blind but I can't seem to find it anywhere. What function will return the time a file was created? I see filemtime(...) returns the time that file was last Modified and...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
4
by: KC Eric | last post by:
Hi everyone, How can one encrypt an entire file? What I mean is not simply encrypting the content of the file, but also the file's property(e.g. file creation date, file's name, access right,...
2
by: opswat | last post by:
Hello, I am currently working on a C++ project for a PocketPC with Windows Mobile 5.0 in Visual Studio 2005. I am currently looking for a way to get file version information, i.e. file...
1
by: Vikash | last post by:
Say Im going to create a new class called "master.cs" if i created this file , by default file and author information should be added at the top of the file. Example ...
2
by: levimc | last post by:
I know that that topic may be old to you but I looked at other more- than-two-year-old topics related to mine. However, I didn't find them working for my project at all because its errors return...
7
helpwithcode
by: helpwithcode | last post by:
Hi people, I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements, String string_dob=text_dob.getText(); //Converting string to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.