In C#, what's the simplest/safest/shortest way to make a file appear as though it has been modified (i.e. its last modified date) without changing the contents of the file?
+5
A:
System.IO.File.SetLastWriteTimeUtc(fileName, DateTime.UtcNow);
Matt Howells
2009-11-11 16:44:19
I wonder if you posted this question just to get rep.
Josh Stodola
2009-11-11 16:47:14
@Josh SO doesn't give you points for answering your own questions. From time to time I answer my own if I find a good answer while awaiting feedback from others. There's no reason you shouldn't contribute just because you were the one that asked.
David Lively
2009-11-11 16:50:10
@David He has gained 46 rep points thus far with this question. I believe he only posted this question because he wanted the rep. In otherwords, he had no reason to ask the question (because he knew the answer).
Josh Stodola
2009-11-11 17:19:16
Josh, just read the FAQ.
Henk Holterman
2009-11-11 18:15:18
@Josh, I do not need the rep, it is a genuine question. After asking the question I worked out a way to do it and posted my solution. If you know of a better way please post your answer.
Matt Howells
2009-11-12 09:03:07