File upload date and Time

C

Chris Strobel

Is there a way using the Input Type=File and ASP.NET to keep the original
date and time stamp of files I'm uploading? If not, what about getting the
original date and time stamps and changing them after the file is uploaded
to the server?

Thanks,
Chris
 
M

Marshal Antony

Hi Chris,
You can use File.GetLastWriteTime to get the date and time the
specified file or directory was last written to.
In C# for eg:
string file_path=@"c:\test\yourfile.txt";
DateTime dt=File.GetLastWriteTime(file_path);

In VB.NET
Dim file_path As String = "c:\test\yourfile.txt"

Dim dt As DateTime = File.GetLastWriteTime(file_path)

If you want to set the last write time to
some date and time you want :
For Eg:
In C#
File.SetLastWriteTime(file_path, DateTime.Now);
In VB.NET
File.SetLastWriteTime(file_path, DateTime.Now)
This will update the last write time to the current
time.

Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,052
Latest member
KetoBeez

Latest Threads

Top