本文整理汇总了C#中FileSystemEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# FileSystemEventHandler类的具体用法?C# FileSystemEventHandler怎么用?C# FileSystemEventHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemEventHandler类属于命名空间,在下文中一共展示了FileSystemEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileWatcher
public FileWatcher(string filepath, FileChangedHandler handler)
: base(System.IO.Path.GetDirectoryName(filepath),
System.IO.Path.GetFileName(filepath))
{
FilePath = filepath;
Handler = handler;
NotifyFilter =
NotifyFilters.FileName |
NotifyFilters.Attributes |
NotifyFilters.LastAccess |
NotifyFilters.LastWrite |
NotifyFilters.Security |
NotifyFilters.Size;
Changed += new FileSystemEventHandler(delegate(object sender, FileSystemEventArgs e)
{
// TODO : Find alternative !!
/*
System.Windows.Application.Current.Dispatcher.BeginInvoke(
new VoidDelegate(this.FileChanged));
*/
});
UpdateFileInfo();
Timer = new Timer(100);
Timer.AutoReset = false;
Timer.Elapsed += new ElapsedEventHandler(delegate(object sender, ElapsedEventArgs e)
{
// TODO : Find alternative !!
/*
System.Windows.Application.Current.Dispatcher.BeginInvoke(
new VoidDelegate(this.TimerElapsed));
*/
});
EnableRaisingEvents = true;
}
示例2: OnChangeOrCreation
public static FileSystemWatcher OnChangeOrCreation(this FileSystemWatcher watcher, FileSystemEventHandler handler)
{
watcher.Changed += handler;
watcher.Created += handler;
return watcher;
}
示例3: InitFormOnce
private void InitFormOnce()
{
cboProfile.SelectedIndexChanged += new EventHandler(cboProfile_SelectedIndexChanged);
_textFileChangedHandler = new FileSystemEventHandler(_host_TextFileChanged);
_host.TextFileChanged += _textFileChangedHandler;
LoadProfiles();
PluginUtils.InitPluginGrid(dgvPlugin);
#region Init values
nudLoopCount.Value = Config.DeobfFlowOptionBranchLoopCount;
nudMaxRefCount.Value = Config.DeobfFlowOptionMaxRefCount;
txtRegex.Text = Config.LastRegex;
InitBranchDirection(cboDirection);
if (Config.DeobfFlowOptionBranchDirection >= 0 && Config.DeobfFlowOptionBranchDirection < cboDirection.Items.Count)
{
cboDirection.SelectedIndex = Config.DeobfFlowOptionBranchDirection;
}
else
{
cboDirection.SelectedIndex = 0;
}
#endregion
}
示例4: GetDocument
internal static IDocument GetDocument(string fullPath, FileSystemEventHandler fileDeletedCallback = null)
{
if (string.IsNullOrWhiteSpace(fullPath))
{
return null;
}
var fileName = fullPath.ToLowerInvariant();
IDocument currentDocument;
if (DocumentLookup.TryGetValue(fileName, out currentDocument))
{
return currentDocument;
}
var factory = GetFactory(fileName);
if (factory == null)
{
return null;
}
currentDocument = factory(fullPath, fileDeletedCallback);
if (currentDocument == null)
{
return null;
}
return DocumentLookup.AddOrUpdate(fileName, x => currentDocument, (x, e) => currentDocument);
}
示例5: FileWacher
/// <summary>
/// Will create a FileSystemWatcher on every directory, including and contained in the directory passed in
/// </summary>
/// <param name="basepath">directory path</param>
/// <param name="handler">Method, signature must accept object, FileSystemEventArgs</param>
public FileWacher(string basepath, FileSystemEventHandler handler)
{
_basepath = basepath;
_watchers = new List<FileSystemWatcher>();
_handler = handler;
BuildWatchers(_basepath);
}
示例6: CreateWatch
void CreateWatch(string dirPath, FileSystemEventHandler handler)
{
if (_watchers.ContainsKey(dirPath))
{
_watchers[dirPath].Dispose();
_watchers[dirPath] = null;
}
if (!Directory.Exists(dirPath)) return;
var watcher = new FileSystemWatcher();
watcher.IncludeSubdirectories = false;//includeSubdirectories;
watcher.Path = dirPath;
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size;
watcher.Filter = "*";
watcher.Changed += handler;
watcher.EnableRaisingEvents = true;
watcher.InternalBufferSize = 10240;
//return watcher;
_watchers[dirPath] = watcher;
foreach (var childDirPath in Directory.GetDirectories(dirPath))
{
CreateWatch(childDirPath, handler);
}
}
示例7: FileChangeEventTarget
internal FileChangeEventTarget(string fileName, OnChangedCallback onChangedCallback) {
_fileName = fileName;
_onChangedCallback = onChangedCallback;
_changedHandler = new FileSystemEventHandler(this.OnChanged);
_errorHandler = new ErrorEventHandler(this.OnError);
_renamedHandler = new RenamedEventHandler(this.OnRenamed);
}
示例8: SetChangedHandler
public void SetChangedHandler(FileSystemEventHandler handler)
{
if (_fileWatcher != null)
{
_fileWatcher.Changed += handler;
}
}
示例9: RemoveChangedHandler
public void RemoveChangedHandler(FileSystemEventHandler handler)
{
if (_fileWatcher != null)
{
_fileWatcher.Changed -= handler;
}
}
示例10: dynFileReader
public dynFileReader()
{
handler = new FileSystemEventHandler(watcher_FileChanged);
InPortData.Add(new PortData("path", "Path to the file", typeof(string)));
OutPortData.Add(new PortData("contents", "File contents", typeof(string)));
NodeUI.RegisterAllPorts();
}
示例11: dynFileReader
public dynFileReader()
{
this.handler = new FileSystemEventHandler(watcher_FileChanged);
InPortData.Add(new PortData("path", "Path to the file", typeof(string)));
OutPortData = new PortData("contents", "File contents", typeof(string));
base.RegisterInputsAndOutputs();
}
示例12: FileSystemWatcherOptions
public FileSystemWatcherOptions(string path, string filter, FileSystemEventHandler changedAction, FileSystemEventHandler createdAction, ErrorEventHandler errorAction, FileSystemEventHandler deletedAction, RenamedEventHandler renamedAction)
{
Path = path;
Filter = filter;
ChangedAction = changedAction;
CreatedAction = createdAction;
ErrorAction = errorAction;
DeletedAction = deletedAction;
RenamedAction = renamedAction;
}
示例13: WrapFileDescriptor
public WrapFileDescriptor(string path, IWrapRepository wraps, FileSystemEventHandler handler)
{
Repository = wraps;
Clients = new List<IWrapAssemblyClient>();
FilePath = path;
FileSystemWatcher = new FileSystemWatcher(Path.GetDirectoryName(path), Path.GetFileName(path))
{
NotifyFilter = NotifyFilters.LastWrite
};
FileSystemWatcher.Changed += handler;
FileSystemWatcher.EnableRaisingEvents = true;
}
示例14: FileWatcher
/// <summary>
/// Create watcher for the specified file and monitor changes
/// </summary>
/// <param name="file_changed_func"></param>
public FileWatcher(FileSystemEventHandler file_changed_func)
{
watcher = new FileSystemWatcher();
watcher.Path = Config.get_game_path();
//Always check the last write to the file
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Filter = "Chat.log";
//Callback
watcher.Changed += new FileSystemEventHandler(file_changed_func);
//Start watching
watcher.EnableRaisingEvents = true;
}
示例15: FolderChangeWatcher
/// <summary>
/// Watches a folder for folder creation
/// </summary>
/// <param name="path">Which folder or fileshare to watch</param>
/// <param name="actionOnFolderCreated">Action to perform when a change is detected. The action is invoked asynchronosly</param>
public FolderChangeWatcher(string path, FileSystemEventHandler actionOnFolderCreated)
{
if (actionOnFolderCreated == null)
throw new ArgumentNullException("actionOnFolderCreated");
_actionOnFolderCreated = actionOnFolderCreated;
_watcher = new FileSystemWatcher(path);
_watcher.Created += OnFolderCreated;
_watcher.InternalBufferSize = 16384; //16KB buffer instead of 4KB (default).
_watcher.IncludeSubdirectories = false;
_watcher.EnableRaisingEvents = true;
}