コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: file.cs プロジェクト: wolewd/Windows-Server-2003
        /// <include file='doc\File.uex' path='docs/doc[@for="File.SetLastWriteTimeUtc"]/*' />
        public static void SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
        {
            IntPtr     handle = Win32Native.INVALID_HANDLE_VALUE;
            FileStream fs     = OpenFile(path, FileAccess.Write, ref handle);

            bool r = Win32Native.SetFileTime(handle, null, null, new long[] { lastWriteTimeUtc.ToFileTimeUtc() });

            if (!r)
            {
                int errorCode = Marshal.GetLastWin32Error();
                fs.Close();
                __Error.WinIOError(errorCode, path);
            }
            fs.Close();
        }
コード例 #3
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();
        }