예제 #1
0
        // Default values indicate "no change".  Use defaults so that we don't force callsites to be aware of the default values
        internal unsafe static bool SetFileTime(SafeFileHandle hFile, long creationTime = -1, long lastAccessTime = -1,
                                                long lastWriteTime = -1, long changeTime = -1, uint fileAttributes = 0)
        {
            Interop.FILE_BASIC_INFO basicInfo = new Interop.FILE_BASIC_INFO()
            {
                CreationTime   = creationTime,
                LastAccessTime = lastAccessTime,
                LastWriteTime  = lastWriteTime,
                ChangeTime     = changeTime,
                FileAttributes = fileAttributes
            };

            return(Interop.mincore.SetFileInformationByHandle(hFile, Interop.FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo, ref basicInfo, (uint)Marshal.SizeOf <Interop.FILE_BASIC_INFO>()));
        }
예제 #2
0
        // Default values indicate "no change".  Use defaults so that we don't force callsites to be aware of the default values
        internal unsafe static bool SetFileTime(SafeFileHandle hFile, long creationTime = -1, long lastAccessTime = -1,
            long lastWriteTime = -1, long changeTime = -1, uint fileAttributes = 0)
        {
            Interop.FILE_BASIC_INFO basicInfo = new Interop.FILE_BASIC_INFO()
            {
                CreationTime = creationTime,
                LastAccessTime = lastAccessTime,
                LastWriteTime = lastWriteTime,
                ChangeTime = changeTime,
                FileAttributes = fileAttributes
            };

            return Interop.mincore.SetFileInformationByHandle(hFile, Interop.FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo, ref basicInfo, (uint)Marshal.SizeOf<Interop.FILE_BASIC_INFO>());
        }