Exemplo n.º 1
0
        protected AbstractJournalScanner(string scanFolder, IFileRecordListener recordListener, IFileRecordFilter recordFilter = null)
        {
            this.scanFolder     = Path.GetFullPath(scanFolder);
            this.recordFilter   = recordFilter;
            this.recordListener = recordListener;
            var driveLetterRegex = new Regex(DriveLetterRegexString);
            var driveLetterMatch = driveLetterRegex.Match(this.scanFolder);

            if (driveLetterMatch.Success)
            {
                this.driveLetter = driveLetterMatch.Groups.Values.ElementAt(1).Value.ToUpper()[0]; //extract first letter in upper case
            }
            else
            {
                throw new ArgumentException($"invalid scanFolder path: {this.scanFolder}");
            }

            var drivePath = $"\\\\.\\{driveLetter}:";

            this.volumeHandle = Kernel32.CreateFile(drivePath, FileAccess.Read, FileShare.ReadWrite, IntPtr.Zero, FileMode.Open, FileAttributes.Normal, IntPtr.Zero);

            if (volumeHandle.IsInvalid)
            {
                var lastError   = Win32Exception.GetLastWin32Error();
                var hintMessage = lastError == Win32Error.ERROR_ACCESS_DENIED ? ". Try Run As Administrator" : string.Empty;
                throw new Win32Exception(lastError, $"{new Win32Exception(lastError).Message} for path: \"{drivePath}\" {hintMessage}");
            }

            this.usnIo = new UsnDeviceWrapper(volumeHandle, true);
        }
Exemplo n.º 2
0
 public SimpleJournalScanner(string scanFolder, IFileRecordListener recordListener, IFileRecordFilter recordFilter = null)
     : base(scanFolder, recordListener, recordFilter)
 {
     this.extendedContextPath = $"\\\\?\\{scanFolder}";  //  sample path: \\?\D:\test\test.txt
 }
Exemplo n.º 3
0
 public SimpleFileRecordScanner(string scanFolder, IFileRecordListener recordListener, IFileRecordFilter recordFilter = null)
 {
     this.scanFolder     = scanFolder;
     this.recordListener = recordListener;
     this.recordFilter   = recordFilter;
 }