What you want to achieve through following line of code?
File.SetLastWriteTime(path, new DateTime());
If you want to set current datetime as LastWriteTime, try following-
File.SetLastWriteTime(path, DateTime.Now);
If you still experience the same error or if your requirement is something else, please let me know.
:)