public FileSystemWatcherEventArgs( string name, string fullPath, FileSystemWatcherChangeType changeType) { this.Name = name; this.FullPath = fullPath; this.ChangeType = changeType; }
public FileSystemWatcherRenameEventArgs( string name, string fullPath, FileSystemWatcherChangeType changeType, string oldName, string oldPath) : base(name, fullPath, changeType) { this.OldName = oldName; this.OldPath = oldPath; }
private void ReportChangeType(FileListEnum current, CancellationToken token, Action <object, WatcherCallbackArgs> report, FileSystemWatcherChangeType changeType) { if (token.IsCancellationRequested) { throw new OperationCanceledException(); } foreach (var file in current) { Trace.TraceInformation($"Reporting changes in directory: {_settings.ScanDirectory} file: {file} changetype: {changeType}"); report(this, new WatcherCallbackArgs(file.Key, changeType)); } }
void CreateFileHelper(Func <string, FileStream> createFileBefore, Func <string, FileStream> createFileAfter, FileSystemWatcherChangeType type) { var scanDirectory = GetAndPrepareTempDirectory(); FileStream fileBefore = createFileBefore?.Invoke(scanDirectory); var m = new ManualScanPhysicalFileSystemWatcher(new ManualScanPhysicalFileSystemWatcherSettings { ScanDirectory = scanDirectory, ScanSpeedInSeconds = 0 }); ManualResetEvent changeDetected = new ManualResetEvent(false); ManualResetEvent scanInitialized = new ManualResetEvent(false); m.Open(new FilterAndCallbackArgument(String.Empty, (o, args) => { if (args.ChangeType == type) { changeDetected.Set(); } }, o => { scanInitialized.Set(); })); var completedScan = scanInitialized.WaitOne(500); Assert.True(completedScan); FileStream file = createFileAfter?.Invoke(scanDirectory); var completed = changeDetected.WaitOne(500); Assert.True(completed); file?.Dispose(); fileBefore?.Dispose(); m.Dispose(); DeleteAndReturnTempDirectoryName(); }
public WatcherCallbackArgs(string fileName, FileSystemWatcherChangeType changeType) { FileName = fileName; ChangeType = changeType; }
// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local void CheckHelper(FilterAndCallbackArgument local, string fileName, ref FileEntry lastEntry, FileSystemWatcherChangeType ft) { local.ActionChanges(this, new WatcherCallbackArgs(fileName, ft)); Assert.True(lastEntry?.FileName == fileName && lastEntry?.LastChanges == ft); }