public static unsafe void SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc) { if (Common.IsRunningOnMono() && Common.IsPlatformUnix()) { SysFile.SetLastWriteTimeUtc(path, lastWriteTimeUtc); return; } string normalizedPath = Path.NormalizeLongPath(path); using (SafeFileHandle handle = GetFileHandle(normalizedPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite, FileOptions.None)) { var fileTime = new NativeMethods.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc()); bool r = NativeMethods.SetFileTime(handle, null, null, &fileTime); if (!r) { int errorCode = Marshal.GetLastWin32Error(); Common.ThrowIOError(errorCode, path); } } }