本文整理汇总了C#中System.IO.FileSystemWatcher.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystemWatcher.EndInit方法的具体用法?C# FileSystemWatcher.EndInit怎么用?C# FileSystemWatcher.EndInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileSystemWatcher
的用法示例。
在下文中一共展示了FileSystemWatcher.EndInit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileWatcher
public FileWatcher(string directory, string filter)
{
_dispatcher = Dispatcher.CurrentDispatcher;
_watcher = new FileSystemWatcher();
_watcher.BeginInit();
_watcher.Path = directory;
_watcher.Filter = filter;
_watcher.IncludeSubdirectories = false;
_watcher.InternalBufferSize = InitialBufferSize;
_watcher.NotifyFilter
= NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastWrite
| NotifyFilters.Attributes
| NotifyFilters.Security
| NotifyFilters.Size;
// note: all events are on threadpool threads!
_watcher.Created += onCreated;
_watcher.Deleted += onDeleted;
_watcher.Changed += onChanged;
_watcher.Renamed += onRenamed;
_watcher.Error += onError;
_watcher.EndInit();
_watcher.EnableRaisingEvents = true;
}
示例2: SNTemplateManager
private SNTemplateManager(string snTmplRuleFilePath)
{
rulesfileWatcher = new FileSystemWatcher();
rulesfileWatcher.BeginInit();
rulesfileWatcher.EnableRaisingEvents = true;
rulesfileWatcher.Filter = "*.rules";
rulesfileWatcher.NotifyFilter = System.IO.NotifyFilters.LastWrite;
rulesfileWatcher.Path = snTmplRuleFilePath;
rulesfileWatcher.Changed += new FileSystemEventHandler(ruleFileWatcher_Changed);
rulesfileWatcher.EndInit();
}
示例3: DeserializedRuleSetsManager
private DeserializedRuleSetsManager()
{
snTmplRuleFilePath = ConfigurationManager.AppSettings["RulePath"].ToString();
irm = RuleSetManagerFactory.CreateFileRuleSetManager();
rulesfileWatcher = new FileSystemWatcher();
rulesfileWatcher.BeginInit();
rulesfileWatcher.EnableRaisingEvents = true;
rulesfileWatcher.Filter = "*.rules";
rulesfileWatcher.NotifyFilter = System.IO.NotifyFilters.LastWrite;
rulesfileWatcher.Path = snTmplRuleFilePath;
rulesfileWatcher.Changed += new FileSystemEventHandler(ruleFileWatcher_Changed);
rulesfileWatcher.EndInit();
}
示例4: OnStart
protected override void OnStart(string[] args)
{
Thread.Sleep(15000);
log = new EventLog();
log.Source = "S1 Payment Operator Service";
setting = new Setting();
files = new ArrayList();
fileWatcher = new FileSystemWatcher();
fileWatcher.BeginInit();
fileWatcher.IncludeSubdirectories = false;
fileWatcher.Filter = "*.txt";
fileWatcher.Path = setting.incomingFolder;
fileWatcher.Created += new FileSystemEventHandler(OnFileCreated);
fileWatcher.EnableRaisingEvents = true;
fileWatcher.EndInit();
}
示例5: Watch
public IDisposable Watch(DirectoryInfo scriptPath)
{
var watcher = new FileSystemWatcher(scriptPath.FullName);
watcher.BeginInit();
watcher.Path = scriptPath.FullName;
watcher.EnableRaisingEvents = true;
watcher.Error += OnError;
watcher.Changed += OnChanged;
watcher.Created += OnCreated;
watcher.Deleted += OnDeleted;
watcher.Renamed += OnRenamed;
watcher.EndInit();
return new Disposable(() => watcher.Dispose());
}
示例6: Watcher
public Watcher(string path, Action<string> receiver)
{
// important to append the path with a directory separator,
// so that stripping works as expected!
if (!path.EndsWith(DirectorySeparatorString))
path += DirectorySeparatorString;
_path = path;
_receiver = receiver;
_watcher = new FileSystemWatcher();
_watcher.BeginInit();
_watcher.Filter = string.Empty;
_watcher.IncludeSubdirectories = true;
_watcher.InternalBufferSize = InitialBufferSize;
_watcher.Path = path;
_watcher.NotifyFilter
= NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastWrite
// we want attributes to catch error-fixups
| NotifyFilters.Attributes
| NotifyFilters.Security;
// we assume that size changes are covered by LastWrite
// | NotifyFilters.Size;
// note: all events are on threadpool threads!
_watcher.Created += onCreated;
_watcher.Deleted += onDeleted;
_watcher.Changed += onChanged;
_watcher.Renamed += onRenamed;
_watcher.Error += onError;
_watcher.EndInit();
_watcher.EnableRaisingEvents = true;
}
示例7: ListenForChanges
public static void ListenForChanges(string currentDirectory)
{
var watcher = new FileSystemWatcher(currentDirectory)
{
NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Size | NotifyFilters.LastWrite,
EnableRaisingEvents = true,
IncludeSubdirectories = true,
InternalBufferSize = 16777216
};
watcher.BeginInit();
watcher.Changed += watcher_Changed;
watcher.Created += watcher_Changed;
watcher.Deleted += watcher_Changed;
watcher.Renamed += watcher_Changed;
watcher.EndInit();
while (true)
{
// begin event loop for watcher
System.Threading.Thread.Sleep(100);
ProcessQueueItem();
}
}
示例8: CreateFileSystemWatcher
/// <summary>
/// Creates the instance of <see cref="FileSystemWatcher" /> used
/// to monitor the file system.
/// </summary>
/// <returns>
/// An instance of <see cref="FileSystemWatcher" /> that will be
/// used to monitor the directory for the creation/modification
/// of log files.
/// </returns>
/// <remarks>
/// <see cref="CreateFileSystemWatcher" /> will be called from within
/// a synchronized context so derived classes should not attempt to
/// perform any additional synchronization themselves.
/// </remarks>
protected virtual FileSystemWatcher CreateFileSystemWatcher()
{
Contract.Ensures(Contract.Result<FileSystemWatcher>() != null);
var watcher = new FileSystemWatcher();
watcher.BeginInit();
watcher.Changed += this.watcher_Changed;
watcher.Created += this.watcher_Created;
watcher.EnableRaisingEvents = true;
watcher.Filter = this.Name + "_*.txt";
watcher.IncludeSubdirectories = false;
watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite
| NotifyFilters.DirectoryName | NotifyFilters.FileName;
watcher.Path = this.Path;
watcher.EndInit();
return watcher;
}
示例9: InitLoadBackupJobs
private void InitLoadBackupJobs()
{
LoadBackupJobs();
_backupJobsFileSystemWatcher = new FileSystemWatcher();
if (_backupJobsFileSystemWatcher != null) return;
_backupJobsFileSystemWatcher = new FileSystemWatcher(GlobalSettings.AppDataSettingsPath);
_backupJobsFileSystemWatcher.BeginInit();
_backupJobsFileSystemWatcher.Created += FileSystemWatcherEvent;
_backupJobsFileSystemWatcher.Renamed += FileSystemWatcherRenamed;
_backupJobsFileSystemWatcher.Deleted += FileSystemWatcherEvent;
_backupJobsFileSystemWatcher.Changed += FileSystemWatcherEvent;
_backupJobsFileSystemWatcher.IncludeSubdirectories = true;
_backupJobsFileSystemWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
_backupJobsFileSystemWatcher.EnableRaisingEvents = true;
_backupJobsFileSystemWatcher.EndInit();
}
示例10: OnStart
protected override void OnStart(string[] args)
{
try
{
Log("Service", "Start");
watcher = new FileSystemWatcher();
watcher.BeginInit();
watcher.IncludeSubdirectories = true;
watcher.Path = ResourcePath;
watcher.Created += Watcher_Created;
watcher.EnableRaisingEvents = true;
watcher.EndInit();
Log("Watching", "Start");
Log("Calculating", "Start");
DirectoryInfo info = new DirectoryInfo(ResourcePath);
var dirs = info.GetDirectories("视频", SearchOption.AllDirectories);
foreach (var dir in dirs)
{
var files = dir.GetFiles().Where(o =>
o.Name.EndsWith(".avi", StringComparison.OrdinalIgnoreCase) ||
o.Name.EndsWith(".mpg", StringComparison.OrdinalIgnoreCase) ||
o.Name.EndsWith(".mpeg", StringComparison.OrdinalIgnoreCase) ||
o.Name.EndsWith(".rm", StringComparison.OrdinalIgnoreCase) ||
o.Name.EndsWith(".rmvb", StringComparison.OrdinalIgnoreCase) ||
o.Name.EndsWith(".wmv", StringComparison.OrdinalIgnoreCase)).ToList();
var table = engine.OpenXTable<string, ConvertingResource>("Video");
foreach (var file in files)
{
var path = file.FullName;
var target = path.Substring(0, path.LastIndexOf('.')) + TagetExtension;
if (!File.Exists(target))
{
table[path] = new ConvertingResource { Target = target, Started = false };
Log("Todo", string.Format("{0} --> {1}", path, target));
}
}
engine.Commit();
}
Log("Calculating", "Calculated");
StartConvert();
}
catch (Exception exception)
{
try { watcher.Dispose(); } catch { }
Log("Error", exception.StackTrace.ToString(CultureInfo.InvariantCulture));
}
}
示例11: RefreshUploadContent
public void RefreshUploadContent()
{
ThreadPool.QueueUserWorkItem(delegate (object state) {
VGen0 method = null;
VGen1 gen2 = null;
try
{
this.CancelUploadSearch = true;
while (this.ScanningForUploads)
{
Thread.Sleep(20);
}
this.CancelUploadSearch = false;
try
{
this.ScanningForUploads = true;
if (!base.Disposing && !base.IsDisposed)
{
if (method == null)
{
method = delegate {
this.PreviousUploadStatus = Loc.Get("<LOC>Searching for content...");
if (!AdditionalContent.UploadingContent)
{
this.NodeUploadSearch.Text = this.PreviousUploadStatus;
}
};
}
IAsyncResult result = base.BeginInvoke(method);
FileSystemWatcher[] array = new FileSystemWatcher[this.UploadMonitors.Values.Count];
this.UploadMonitors.Values.CopyTo(array, 0);
foreach (FileSystemWatcher watcher in array)
{
if (!Program.Settings.Content.Upload.UploadPaths.Contains(watcher.Path))
{
this.UploadMonitors.Remove(watcher.Path);
}
}
foreach (string str in Program.Settings.Content.Upload.UploadPaths.ToArray())
{
if (!Directory.Exists(str))
{
Program.Settings.Content.Upload.UploadPaths.Remove(str);
}
}
foreach (string str in Program.Settings.Content.Upload.UploadPaths)
{
if (!this.UploadMonitors.ContainsKey(str))
{
FileSystemWatcher watcher = new FileSystemWatcher(str);
watcher.BeginInit();
watcher.EnableRaisingEvents = true;
watcher.IncludeSubdirectories = true;
watcher.Created += new FileSystemEventHandler(this.UploadFileAdded);
watcher.Deleted += new FileSystemEventHandler(this.UploadFileDeleted);
watcher.Renamed += new RenamedEventHandler(this.UploadFileRenamed);
watcher.Changed += new FileSystemEventHandler(this.UploadFileChanged);
watcher.EndInit();
this.UploadMonitors[str] = watcher;
}
}
foreach (TreeNode node in this.treeViewUpload.Nodes.Find("AvailableUploads", false))
{
this.CheckExistence(node);
}
this.CheckCachedLocations();
foreach (string str in Program.Settings.Content.Upload.UploadPaths)
{
this.RefreshUploadContent(str);
}
if (!this.CancelUploadSearch)
{
List<TreeNode> list = new List<TreeNode>();
foreach (TreeNode node in this.treeViewUpload.Nodes)
{
TreeNode[] dest = new TreeNode[node.Nodes.Count];
node.Nodes.CopyTo(dest, 0);
list.AddRange(dest);
}
int total = 0;
foreach (TreeNode node in list)
{
if (this.CancelUploadSearch)
{
return;
}
if ((node != this.NodeUploadSearch) && (node.Nodes.Count == 0))
{
if (base.Disposing || base.IsDisposed)
{
return;
}
base.Invoke((VGen1)delegate (object s) {
(s as TreeNode).Remove();
}, new object[] { node });
continue;
}
ContentType tag = node.Tag as ContentType;
if (tag != null)
{
//.........这里部分代码省略.........
示例12: CreateFileSystemWatcher
protected FileSystemWatcher CreateFileSystemWatcher(string directory)
{
//Console.WriteLine("Watcher creating {0}", directory);
var watcher = new FileSystemWatcher()
{
Path = directory,
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
Filter = FileFilter,
IncludeSubdirectories = true
};
watcher.BeginInit();
watcher.Changed += OnModified;
watcher.Created += OnModified;
watcher.Deleted += OnModified;
watcher.Renamed += OnModified;
watcher.Error += WatcherOnError;
watcher.EndInit();
watcher.EnableRaisingEvents = true;
//Console.WriteLine("Watcher created {0}", directory);
return watcher;
}
示例13: InitializeFileSystemWatcher
void InitializeFileSystemWatcher(string path)
{
if (folderWatcher != null)
{
folderWatcher.Dispose();
}
folderWatcher = new FileSystemWatcher(path, "*.bin");
folderWatcher.BeginInit();
folderWatcher.Changed += OnFolderWatcherChanged;
folderWatcher.Created += OnFolderWatcherCreated;
folderWatcher.Deleted += OnFolderWatcherDeleted;
folderWatcher.EnableRaisingEvents = true;
folderWatcher.IncludeSubdirectories = false;
folderWatcher.SynchronizingObject = this;
folderWatcher.EndInit();
}
示例14: Main
static void Main(string[] args)
{
var path = args.Length == 0 ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Diablo III\Screenshots" : args[0];
if (args.Length == 3)
{
Size = new Rectangle(int.Parse(args[1].Split('x')[0]), int.Parse(args[1].Split('x')[1]),
int.Parse(args[2].Split('x')[0]), int.Parse(args[2].Split('x')[1]));
ResetSize = false;
}
Console.WriteLine("Registering filesystem events. ({0})", path);
watcher = new FileSystemWatcher(path, "*.jpg");
watcher.BeginInit();
watcher.EnableRaisingEvents = true;
watcher.Created += WatcherOnCreated;
watcher.EndInit();
while (true)
{
Thread.Sleep(1000);
}
}
示例15: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent ()
{
this.ObserveImportDirectoryFileSystemWatcher = (new System.IO.FileSystemWatcher());
ObserveImportDirectoryFileSystemWatcher.BeginInit();
//
// ObserveImportDirectoryFileSystemWatcher
//
this.ObserveImportDirectoryFileSystemWatcher.EnableRaisingEvents = true;
this.ObserveImportDirectoryFileSystemWatcher.Filter = "*.av*";
this.ObserveImportDirectoryFileSystemWatcher.NotifyFilter = (System.IO.NotifyFilters)((((System.IO.NotifyFilters.FileName | System.IO.NotifyFilters.DirectoryName)
| System.IO.NotifyFilters.Size)
| System.IO.NotifyFilters.LastWrite));
this.ObserveImportDirectoryFileSystemWatcher.Created += new FileSystemEventHandler(ObserveImportDirectoryFileSystemWatcher_Created);
this.ObserveImportDirectoryFileSystemWatcher.Deleted += new FileSystemEventHandler(ObserveImportDirectoryFileSystemWatcher_Deleted);
this.ObserveImportDirectoryFileSystemWatcher.Renamed += new RenamedEventHandler(ObserveImportDirectoryFileSystemWatcher_Renamed);
this.ObserveImportDirectoryFileSystemWatcher.Changed += new FileSystemEventHandler(ObserveImportDirectoryFileSystemWatcher_Changed);
// PreparePlayableMaterialDLL
//
//this.CanPauseAndContinue = true;
//this.ServiceName = "PreparePlayableMaterialDLL";
ObserveImportDirectoryFileSystemWatcher.EndInit();
}