/// <summary> /// Sets the time at which the file or directory was last written to (UTC) /// </summary> /// <param name="pathInfo">Affected file or directory</param> /// <param name="utcTime">The time that is to be used (UTC)</param> public static void SetLastWriteTimeUtc(PathInfo pathInfo, DateTime utcTime) { long longTime = utcTime.ToFileTime(); using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc)) { if (Win32SafeNativeMethods.SetLastWriteFileTime(fileHandle, IntPtr.Zero, IntPtr.Zero, ref longTime)) { return; } int win32Error = Marshal.GetLastWin32Error(); NativeExceptionMapping(pathInfo.FullName, win32Error); } }
/// <summary> /// Sets the time at which the file or directory was last written to (UTC) /// </summary> /// <param name="pathInfo">Affected file or directory</param> /// <param name="utcTime">The time that is to be used (UTC)</param> public static void SetLastWriteTimeUtc(QuickIOPathInfo pathInfo, DateTime utcTime) { Contract.Requires(pathInfo != null); long longTime = utcTime.ToFileTime(); using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc)) { if (!Win32SafeNativeMethods.SetLastWriteFileTime(fileHandle, IntPtr.Zero, IntPtr.Zero, ref longTime)) { int win32Error = Marshal.GetLastWin32Error(); Win32ErrorCodes.NativeExceptionMapping(pathInfo.FullName, win32Error); } } }