/// <summary> /// Sets the time at which the file or directory was last accessed 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 SetLastAccessTimeUtc(PathInfo pathInfo, DateTime utcTime) { long longTime = utcTime.ToFileTime(); using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc)) { if (Win32SafeNativeMethods.SetLastAccessFileTime(fileHandle, IntPtr.Zero, ref longTime, IntPtr.Zero)) { return; } int win32Error = Marshal.GetLastWin32Error(); NativeExceptionMapping(pathInfo.FullName, win32Error); } }
/// <summary> /// Sets the time at which the file or directory was last accessed 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 SetLastAccessTimeUtc(QuickIOPathInfo pathInfo, DateTime utcTime) { Contract.Requires(pathInfo != null); long longTime = utcTime.ToFileTime(); using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc)) { if (!Win32SafeNativeMethods.SetLastAccessFileTime(fileHandle, IntPtr.Zero, ref longTime, IntPtr.Zero)) { int win32Error = Marshal.GetLastWin32Error(); Win32ErrorCodes.NativeExceptionMapping(pathInfo.FullName, win32Error); } } }