Get Creation Date Of File?

Hi all

I am looking for a way to find the creation date of file. My application creates a log each day and populates with events from that day. I need to delete that file after x number of days/weeks. The Directory class has a GetCreationTime method but it doesn’t seem to be present in the micro framework:

Does anyone have an alternative?


name the file with the date - 20111121 was yesterday, 20110530 was my birthday. Then do some math based on that :slight_smile:

What about:

FileInfo fi = new FileInfo(@ "/SD/folder/app.hex");
Debug.Print("CreationTime: " + fi.CreationTime().ToString());
Debug.Print("LastWriteTime: " + fi.LastWriteTime().ToString());

I don’t know how this work for txt files if you write all time to them…

Thanks for the advice:

@ Brett - I am using the creation date of the file as it name, was just hoping there was an easier way to get this info. Probably have to go down this route. Would be much easier if DateTime had a parse function!

@ Dejan - Thanks for that, unfortunately when I run that code against a file it populate the FileInfo object but the CreationTime field is throwing an IO exception. Not sure what could be causing that?