Beispiel #1
0
        public unsafe static void SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
        {
            SafeFileHandle handle;

            using (OpenFile(path, FileAccess.Write, out handle)) {
                Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc());
                bool r = Win32Native.SetFileTime(handle, null, null, &fileTime);
                if (!r)
                {
                    int errorCode = Marshal.GetLastWin32Error();
                    __Error.WinIOError(errorCode, path);
                }
            }
        }
Beispiel #2
0
        /// <include file='doc\File.uex' path='docs/doc[@for="File.SetLastWriteTime"]/*' />
        public unsafe static void SetLastWriteTime(String path, DateTime lastWriteTime)
        {
            IntPtr     handle = Win32Native.INVALID_HANDLE_VALUE;
            FileStream fs     = OpenFile(path, FileAccess.Write, ref handle);

            Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTime.ToFileTime());
            bool r = Win32Native.SetFileTime(handle, null, null, &fileTime);

            if (!r)
            {
                int errorCode = Marshal.GetLastWin32Error();
                fs.Close();
                __Error.WinIOError(errorCode, path);
            }
            fs.Close();
        }
Beispiel #3
0
 public unsafe static void SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
 {
     SafeFileHandle handle;
     using(OpenFile(path, FileAccess.Write, out handle)) {
         Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc());
         bool r = Win32Native.SetFileTime(handle, null, null, &fileTime);
         if (!r)
         {
              int errorCode = Marshal.GetLastWin32Error();
             __Error.WinIOError(errorCode, path);
         }
     }
 }
Beispiel #4
0
        /// <include file='doc\File.uex' path='docs/doc[@for="File.SetLastWriteTime"]/*' />
        public unsafe static void SetLastWriteTime(String path, DateTime lastWriteTime)
        {
            IntPtr handle = Win32Native.INVALID_HANDLE_VALUE;
            FileStream fs = OpenFile(path, FileAccess.Write, ref handle);

            Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTime.ToFileTime());
            bool r = Win32Native.SetFileTime(handle, null, null, &fileTime);
            if (!r)
            {
                 int errorCode = Marshal.GetLastWin32Error();
                 fs.Close();
                __Error.WinIOError(errorCode, path);
            }
            fs.Close();
        }