Пример #1
0
        /// <summary>
        /// Sets the time at which the file or directory was created (UTC)
        /// </summary>
        /// <param name="pathUnc">Affected file or directory</param>
        /// <param name="utcTime">The time that is to be used (UTC)</param>
        public static void SetCreationTimeUtc(string pathUnc, DateTime utcTime)
        {
            long longTime = utcTime.ToFileTime();

            using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathUnc))
            {
                if (!Win32SafeNativeMethods.SetCreationFileTime(fileHandle, ref longTime, IntPtr.Zero, IntPtr.Zero))
                {
                    int win32Error = Marshal.GetLastWin32Error();
                    Win32ErrorCodes.NativeExceptionMapping(pathUnc, win32Error);
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Sets the time at which the file or directory was created (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 SetCreationTimeUtc(PathInfo pathInfo, DateTime utcTime)
        {
            long longTime = utcTime.ToFileTime();

            using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc))
            {
                if (Win32SafeNativeMethods.SetCreationFileTime(fileHandle, ref longTime, IntPtr.Zero, IntPtr.Zero))
                {
                    return;
                }
                int win32Error = Marshal.GetLastWin32Error();
                NativeExceptionMapping(pathInfo.FullName, win32Error);
            }
        }
Пример #3
0
        /// <summary>
        /// Sets the time at which the file or directory was created (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 SetCreationTimeUtc(QuickIOPathInfo pathInfo, DateTime utcTime)
        {
            Contract.Requires(pathInfo != null);

            long longTime = utcTime.ToFileTime();

            using (SafeFileHandle fileHandle = OpenReadWriteFileSystemEntryHandle(pathInfo.FullNameUnc))
            {
                if (!Win32SafeNativeMethods.SetCreationFileTime(fileHandle, ref longTime, IntPtr.Zero, IntPtr.Zero))
                {
                    int win32Error = Marshal.GetLastWin32Error();
                    Win32ErrorCodes.NativeExceptionMapping(pathInfo.FullName, win32Error);
                }
            }
        }