This question already has answers here:
Check last modified date of file in C#
(5 answers)
Closed 9 years ago.
How do I read the modify date of the file in C#?
I can read the creation date of the file by using the code below:
ModifyDate = File.GetCreationTime(FilePath)
File.GetLastWriteTime will do the job
I believe you're looking for GetLastWriteTime
Related
This question already has answers here:
Parse string to DateTime in C#
(9 answers)
Closed 6 months ago.
This line is parsed DateTime.Parse("08/08/2000 00:00:00")
This line isn't parsed DateTime.Parse("08/24/2000 00:00:00")
Question is very simple and stupid, I'm sorry but can't figure out why.
This is likely a localization issue, where it's trying to parse in day/month/year format, and you're assuming it's month/day/year format.
This question already has answers here:
How to edit the modified date of a folder/file?
(2 answers)
Closed 4 years ago.
In my Local folder I have a file sample.txt.
On rightclick -> properties -> Details
I can see its modified date. For example 30.10.2018 09:00.
Can I change this property trough UWP? To 20.10.2018 09:00 for example.
Yes you can do it by the following way
string path = #"c:\sample.txt";
// Take an action that will affect the write time.
File.SetLastWriteTime(path, new DateTime(1985,4,3));
This question already has answers here:
C# DateTime to "YYYYMMDDHHMMSS" format
(18 answers)
Closed 4 years ago.
How can we obtain the current date in format yyyy.MM.dd in C# ASP.NET?
using DateTime.Now
Simply by using
string date = DateTime.Now.ToString("yyyy.MM.dd");
See this documentation for more info on custom date and time formats.
This question already has answers here:
Getting Date or Time only from a DateTime Object
(7 answers)
Closed 8 years ago.
I know that, Example: DateTime fileCreatedDate = File.GetCreationTime(#"C:\Example\MyTest.txt");will return the date and time of a folder creation but how do I only get the "Date"Example "2014-12-01" or "Decemeber 12,2014" of the folder creation excluding the time?
You can use the DateTime.Date property for that, i.e. fileCreatedDate.Date.
This question already has answers here:
How do I get %LocalAppData% in c#?
(2 answers)
Closed 5 years ago.
I want to read the content of the folder located at %LOCALAPPDATA%. But it fails when I tried
Directory.GetDirectories("%LOCALAPPDATA%");
I get "The name 'Directory' does not exist in the current context"
Please help.
Environment.ExpandEnvironmentVariables