Пример #1
0
        private UInt64 FrnFromPath(string pszPath)
        {
            UInt64 FRN   = 0;
            IntPtr hPath = PInvokeWin32.CreateFile(pszPath,
                                                   0,
                                                   PInvokeWin32.FILE_SHARE_READ | PInvokeWin32.FILE_SHARE_WRITE,
                                                   IntPtr.Zero,
                                                   PInvokeWin32.OPEN_EXISTING,
                                                   PInvokeWin32.FILE_FLAG_BACKUP_SEMANTICS,
                                                   IntPtr.Zero);

            if (hPath.ToInt32() != PInvokeWin32.INVALID_HANDLE_VALUE)
            {
                PInvokeWin32.BY_HANDLE_FILE_INFORMATION fi = new PInvokeWin32.BY_HANDLE_FILE_INFORMATION();
                bool bRtn = PInvokeWin32.GetFileInformationByHandle(hPath, out fi);
                if (bRtn)
                {
                    UInt64 fileIndexHigh = (UInt64)fi.FileIndexHigh;
                    FRN = (fileIndexHigh << 32) | fi.FileIndexLow;
                }
                else
                {
                    throw new IOException("GetFileInformationbyHandle() returned invalid handle",
                                          new Win32Exception(Marshal.GetLastWin32Error()));
                }
                PInvokeWin32.CloseHandle(hPath);
            }
            else
            {
                throw new IOException("Unable to get frn entry", new Win32Exception(Marshal.GetLastWin32Error()));
            }
            return(FRN);
        }
Пример #2
0
        static public UInt64 InfoFromPath(string pszPath)
        {
            UInt64 ms = 0;

            IntPtr hPath = PInvokeWin32.CreateFile(pszPath,
                                                   0,
                                                   PInvokeWin32.FILE_SHARE_READ | PInvokeWin32.FILE_SHARE_WRITE,
                                                   IntPtr.Zero,
                                                   PInvokeWin32.OPEN_EXISTING,
                                                   PInvokeWin32.FILE_FLAG_BACKUP_SEMANTICS,
                                                   IntPtr.Zero);

            if (hPath.ToInt32() != PInvokeWin32.INVALID_HANDLE_VALUE)
            {
                PInvokeWin32.BY_HANDLE_FILE_INFORMATION fi = new PInvokeWin32.BY_HANDLE_FILE_INFORMATION();
                bool bRtn = PInvokeWin32.GetFileInformationByHandle(hPath, out fi);
                if (bRtn)
                {
                    //System.DateTime dt = System.DateTime.FromFileTime((((long)fi.LastWriteTime.DateTimeHigh) << 32) | fi.LastWriteTime.DateTimeLow);
                    //ms = (Int32)fi.LastWriteTime.DateTimeLow;
                    UInt64 timeHigh = (UInt64)fi.LastWriteTime.DateTimeHigh;
                    timeHigh = (timeHigh << 32) | fi.LastWriteTime.DateTimeLow;
                    ms       = timeHigh;
                }
            }
            PInvokeWin32.CloseHandle(hPath);

            return(ms);
        }
Пример #3
0
        private void GetRootHandle()
        {
            string vol = string.Concat("\\\\.\\", _drive);

            _changeJournalRootHandle = PInvokeWin32.CreateFile(vol,
                                                               PInvokeWin32.GENERIC_READ | PInvokeWin32.GENERIC_WRITE,
                                                               PInvokeWin32.FILE_SHARE_READ | PInvokeWin32.FILE_SHARE_WRITE,
                                                               IntPtr.Zero,
                                                               PInvokeWin32.OPEN_EXISTING,
                                                               0,
                                                               IntPtr.Zero);
            if (_changeJournalRootHandle.ToInt32() == PInvokeWin32.INVALID_HANDLE_VALUE)
            {
                throw new IOException("CreateFile() returned invalid handle",
                                      new Win32Exception(Marshal.GetLastWin32Error()));
            }
        }