当前位置: 首页>>代码示例>>C#>>正文


C# FileSystemWatcher.BeginInit方法代码示例

本文整理汇总了C#中System.IO.FileSystemWatcher.BeginInit方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystemWatcher.BeginInit方法的具体用法?C# FileSystemWatcher.BeginInit怎么用?C# FileSystemWatcher.BeginInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileSystemWatcher的用法示例。


在下文中一共展示了FileSystemWatcher.BeginInit方法的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;
        }
开发者ID:pragmatrix,项目名称:CrossUI,代码行数:30,代码来源:FileWatcher.cs

示例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();
 }
开发者ID:wra222,项目名称:testgit,代码行数:11,代码来源:SNTemplateManager.cs

示例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();
 }
开发者ID:wra222,项目名称:testgit,代码行数:13,代码来源:DeserializedRuleSetsManager.cs

示例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();
        }
开发者ID:yuanrex2012,项目名称:S1-Payment-Operator-Service,代码行数:18,代码来源:S1PaymentService.cs

示例5: AddWatcher

        public void AddWatcher(string path)
        {
            FileSystemWatcher watcher = new FileSystemWatcher();

            watcher.Created += new FileSystemEventHandler(fileCreated);
            watcher.Changed += new FileSystemEventHandler(fileChanged);
            watcher.Deleted += new FileSystemEventHandler(fileDeleted);
            watcher.Renamed += new RenamedEventHandler(fileRenamed);

            watcher.Path = @path;
            watcher.EnableRaisingEvents = true;
            watcher.IncludeSubdirectories = true;
            watcher.BeginInit();

            _watchers.Add(watcher);
            _directories.Add(new DirectoryInfo(path));

            WriteXML();
        }
开发者ID:shafe123,项目名称:UltiDrive,代码行数:19,代码来源:UltiDriveSystemWatcher.cs

示例6: 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());
        }
开发者ID:clbond,项目名称:continuous-runner,代码行数:19,代码来源:Watcher.cs

示例7: 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;
        }
开发者ID:pragmatrix,项目名称:InConcert,代码行数:39,代码来源:Watcher.cs

示例8: 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();
            }
        }
开发者ID:modulexcite,项目名称:pvc,代码行数:24,代码来源:PvcWatcher.cs

示例9: 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;
        }
开发者ID:EtherealWake,项目名称:test-intel,代码行数:33,代码来源:IntelChannel.cs

示例10: 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();
 }
开发者ID:jens13,项目名称:SqlExpressBackupScheduler,代码行数:16,代码来源:BackupEnginService.cs

示例11: AttachToSystem

 public void AttachToSystem()
 {
     #if MONO && DEBUG
     return;
     #endif
     if (_fileSystemWatcher != null) return;
     _fileSystemWatcher = new FileSystemWatcher(ProjectPath);
     _fileSystemWatcher.BeginInit();
     _fileSystemWatcher.Created += FileSystemWatcherCreated;
     _fileSystemWatcher.Renamed += FileSystemWatcherRenamed;
     _fileSystemWatcher.Deleted += FileSystemWatcherDeleted;
     _fileSystemWatcher.IncludeSubdirectories = true;
     _fileSystemWatcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName;
     _fileSystemWatcher.EnableRaisingEvents = true;
     _fileSystemWatcher.EndInit();
 }
开发者ID:sanjayasl,项目名称:custom-rom-creator-studio,代码行数:16,代码来源:CrcsProject.cs

示例12: 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));
     }
 }
开发者ID:Homory-Temp,项目名称:LeYi,代码行数:47,代码来源:HomoryResourceConvertService.cs

示例13: 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;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:25,代码来源:DirectoryWatcher.Windows.cs

示例14: 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();
		}
开发者ID:logtcn,项目名称:SteamKit,代码行数:19,代码来源:MainForm.cs

示例15: 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);
     }
 }
开发者ID:Deathmax,项目名称:D3AHExtractor,代码行数:20,代码来源:Program.cs


注:本文中的System.IO.FileSystemWatcher.BeginInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。