Reputation: 291
I need to find the time when the file was last modified in a day.
Using the below code I only get the date:
System.IO.File.GetLastWriteTime(Server.MapPath("myFile.txt")).ToString("D");
How to get only the time part?
Upvotes: 3
Views: 7870
Reputation: 567
Use HH, mm, ss:
System.IO.File.GetLastWriteTime(Server.MapPath("myFile.txt")).ToString("HH:mm:ss");
Upvotes: 6
Reputation: 3854
May be this will help:
System.IO.File.GetLastWriteTime(@"C:\MyPath\a.txt").TimeOfDay.ToString()
I go this:
17:55:14.3229896
You can format as per your convenience
Upvotes: -1