I have an .NET EXE file . I want to find the file created date and modified date in C# application. Can do it through reflection or with IO stream?
Right click - select Properties. Click the Details tab. Look for the Origin section.
What Happened? When copying files to another storage media, Microsoft Windows™ takes the date of copying as the new file date “Created” and not the original creation date or date taken of the files. Therefore, the date “Created” can even be more recent than the date “Modified”.
Select the file(s) you want to modify or press “Ctrl + A” keys to select all added files. Click the “Actions” tab and select “Change file time / Attributes” options. On the resulting popup, you can edit “Accessed”, “Modified” and “Created” timestamps using the arrow for date and time fields.
You could use below code:
DateTime creation = File.GetCreationTime(@"C:\test.txt"); DateTime modification = File.GetLastWriteTime(@"C:\test.txt");
You can do that using FileInfo
class:
FileInfo fi = new FileInfo("path"); var created = fi.CreationTime; var lastmodified = fi.LastWriteTime;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With