Esempio n. 1
0
        public static unsafe void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
        {
            SafeFileHandle handle;

            using (OpenFile(path, FileAccess.Write, out handle))
            {
                Win32Native.FILE_TIME lastWriteTime = new Win32Native.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc());
                if (!Win32Native.SetFileTime(handle, null, null, &lastWriteTime))
                {
                    __Error.WinIOError(Marshal.GetLastWin32Error(), path);
                }
            }
        }
Esempio n. 2
0
 public static unsafe void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc)
 {
     if ((Environment.OSInfo & Environment.OSName.WinNT) == Environment.OSName.WinNT)
     {
         using (SafeFileHandle handle = OpenHandle(path))
         {
             Win32Native.FILE_TIME lastAccessTime = new Win32Native.FILE_TIME(lastAccessTimeUtc.ToFileTimeUtc());
             if (!Win32Native.SetFileTime(handle, null, &lastAccessTime, null))
             {
                 __Error.WinIOError(Marshal.GetLastWin32Error(), path);
             }
         }
     }
 }
Esempio n. 3
0
 /// <include file='doc\Directory.uex' path='docs/doc[@for="Directory.SetLastAccessTime"]/*' />
 public unsafe static void SetLastAccessTime(String path, DateTime lastAccessTime)
 {
     {
         IntPtr handle = Directory.OpenHandle(path);
         Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastAccessTime.ToFileTime());
         bool r = Win32Native.SetFileTime(handle, null, &fileTime, null);
         if (!r)
         {
             int errorCode = Marshal.GetLastWin32Error();
             Win32Native.CloseHandle(handle);
             __Error.WinIOError(errorCode, path);
         }
         Win32Native.CloseHandle(handle);
     }
 }
 internal static extern void _GetDateNotBefore(SafeCertContextHandle safeCertContext, ref Win32Native.FILE_TIME fileTime);