tags:

views:

263

answers:

2

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
I wonder if you posted this question just to get rep.
Josh Stodola
@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
@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
Josh, just read the FAQ.
Henk Holterman
@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
A: 

Hi Matt,

Couldn't you just open the file and save the file?

Anish Patel