本文整理汇总了C#中System.IO.FileSystemEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# FileSystemEventArgs类的具体用法?C# FileSystemEventArgs怎么用?C# FileSystemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemEventArgs类属于System.IO命名空间,在下文中一共展示了FileSystemEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: m_watcher_Changed
private void m_watcher_Changed(object sender, FileSystemEventArgs e)
{
m_doc = new XmlDocument();
m_doc.Load(m_file);
if (OnFileChange != null)
OnFileChange(this, e);
}
示例2: ConfigurationUpdated
private void ConfigurationUpdated(object sender, FileSystemEventArgs fileSystemEventArgs)
{
if (fileSystemEventArgs.ChangeType != WatcherChangeTypes.Changed) return;
string command = null;
var getCommand = new Func<string>(() =>
{
lock (_watcher)
{
using (var sr = new StreamReader(_filePath))
{
command = sr.ReadLine();
}
using (var sw = new StreamWriter(_filePath, false))
{
sw.Write(String.Empty);
}
return command != null ? command.Trim() : command;
}
});
int maxTries = 0;
while (maxTries < 3)
{
try
{
getCommand();
maxTries = 3;
}
catch (Exception)
{
maxTries++;
Thread.Sleep(1000);
}
}
if (string.IsNullOrEmpty(command)) return;
if (command.StartsWith("STOP:"))
{
var fixtureId = command.Substring(5);
FixtureController.StopFixture(fixtureId);
}
if (command.StartsWith("BLOCK:"))
{
var fixtureId = command.Substring(6);
FixtureController.StopFixture(fixtureId, true);
}
if (command.StartsWith("RESTART:"))
{
var fixtureId = command.Substring("RESTART:".Length);
FixtureController.RestartFixture(fixtureId);
}
}
开发者ID:sportingsolutions,项目名称:SS.Integration.UnifiedDataAPIClient.DotNet,代码行数:60,代码来源:FixtureManager.cs
示例3: FileSystemEvent
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FileSystemEvent(object sender, FileSystemEventArgs e)
{
if (e.FullPath.ToLower() == _filePath.ToLower())
{
if (e.ChangeType == WatcherChangeTypes.Created)
{
this.PerformInitialRead();
}
else if (e.ChangeType == WatcherChangeTypes.Changed)
{
if (_fileStreamReader.BaseStream.Length < _logLength)
{
// if the log has decreased in size, it got reset.
this.PerformInitialRead();
}
else
{
// there was an additive change to the log
_logLength = _fileStreamReader.BaseStream.Length;
var line = "";
while ((line = _fileStreamReader.ReadLine()) != null)
{
this.WriteToLog(line);
}
}
}
}
}
示例4: FileChanged
private void FileChanged(object sender, FileSystemEventArgs e)
{
if (e.ChangeType == WatcherChangeTypes.Changed)
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new DispatcherCallback(delegate() { this.LoadCore(e.FullPath); }));
}
}
示例5: ConfigFileWatcherOnChanged
private void ConfigFileWatcherOnChanged(object sender, FileSystemEventArgs args)
{
string methodName = MethodBase.GetCurrentMethod().Name;
logger.InfoFormat("BEGIN: {0}()", methodName);
try
{
DateTime lastWriteTime = File.GetLastWriteTime(args.FullPath);
if (_lastWriteTime.Equals(lastWriteTime))
return;
_lastWriteTime = lastWriteTime;
ClearCache();
OnConfigSectionChanged();
}
catch (Exception e)
{
logger.Error(methodName, e);
}
finally
{
logger.InfoFormat("END: {0}()", methodName);
}
}
示例6: OnChanged
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
signalRHub = GlobalHost.ConnectionManager.GetHubContext<SignalRTargetHub>();
signalRHub.Clients.All.logEvent("", "", ReadFile(@"C:\temp\log.txt"));
// Specify what is done when a file is changed, created, or deleted.
}
示例7: FileChanged
private static void FileChanged(object sender, FileSystemEventArgs e)
{
var fileInfo = new FileInfo(e.FullPath);
string value;
//do not reset for .js files that are output files except if they are renamed or deleted
if (fileInfo.Extension != ".js" || (e.ChangeType == WatcherChangeTypes.Deleted || e.ChangeType == WatcherChangeTypes.Renamed))
{
CoffeeScriptIncludedFilesMap.RemoveKey(fileInfo.FullName);
CoffeeJavascriptOutputMap.TryRemove(fileInfo.FullName, out value);
foreach (var key in CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName)) {
CoffeeScriptIncludedFilesMap.RemoveKey(key);
CoffeeJavascriptOutputMap.TryRemove(key, out value);
}
}
//reset for re-compilation if .js is included or embedded
if (fileInfo.Extension == ".js" && CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName).Length > 0)
{
foreach (var key in CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName))
{
CoffeeScriptIncludedFilesMap.RemoveKey(key);
CoffeeJavascriptOutputMap.TryRemove(key, out value);
}
}
}
示例8: OnChanged
private void OnChanged(object sender, FileSystemEventArgs e)
{
if (!m_bDirty)
{
m_bDirty = true;
}
}
示例9: fileSystemWatcher_Changed
static void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
{
if (e.Name == FILE_NAME)
{
ReadSettings();
}
}
示例10: Watcher_Created
private void Watcher_Created(object sender, FileSystemEventArgs e)
{
string filepathWatchFolder = e.FullPath;
int retry = 5;
while (retry > 0)
{
try
{
if (File.Exists(filepathWatchFolder))
{
using (FileStream fs = new FileStream(filepathWatchFolder, FileMode.Open, FileAccess.Read))
{
// check if the file is complete
}
}
DebugHelper.WriteLine(string.Format("Created {0}", filepathWatchFolder));
Loader.MainForm.UploadUsingFileSystem(filepathWatchFolder);
break;
}
catch
{
if (--retry == 0)
{
DebugHelper.WriteLine("Unable to open file '" + filepathWatchFolder + "'");
}
Thread.Sleep(500);
}
}
}
示例11: exploitChanged
private void exploitChanged(object sender, FileSystemEventArgs e)
{
try
{
FileInfo f = new FileInfo(e.FullPath);
string date = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
string detect = "";
if (f.Length == 73802 && f.Name.Contains(".exe"))
{
detect = "Likely Meterpreter Executable";
w.write(date, e.FullPath, detect);
}
else if (f.Length == 15872 && f.Name.Contains(".exe"))
{
detect = "Likely PSExec Executable";
w.write(date, e.FullPath, detect);
}
else if (f.Length == 148480 && f.Name.Equals("tior.exe"))
{
detect = "BypassUAC Executable";
w.write(date, e.FullPath, detect);
}
else if (f.Length == 61440 && f.Name.Equals("metsvc.exe"))
{
detect = "Metsvc Installation";
w.write(date, e.FullPath, detect);
}
}
catch (Exception)
{
return;
}
}
示例12: FileWatcher_Changed
static void FileWatcher_Changed(object sender, FileSystemEventArgs e)
{
FileChangeType changeType = e.ChangeType == WatcherChangeTypes.Renamed
? FileChangeType.Renamed
: FileChangeType.Modified;
FireFileChangedEvent(e.FullPath, changeType);
}
示例13: FileSystemWatcherCreated
public void FileSystemWatcherCreated(object sender, FileSystemEventArgs e)
{
Logger.LogInfo("Notified of new SendLink job. Job directory = " + e.FullPath);
string jobDirectory = Path.GetDirectoryName(e.FullPath);
string workingDir = Path.Combine(GetWorkingDirectory(), jobDirectory);
var job = new SkyDoxUploadJob(jobDirectory, _url, workingDir, _userName, "SendLinkJobInfo.xml", new ApiHelper(), _deviceToken);
var uploadJob = new SendLinkJob(job);
if (!_uploadJobs.Any(m => m.Id == uploadJob.Id))
{
uploadJob.OnJobCompleted += uploadJob_OnJobCompleted;
uploadJob.Aborted += uploadJob_OnJobCompleted;
uploadJob.OnError += uploadJob_OnErrorOccurred;
uploadJob.OnJobStatusChanged += UploadJobOnJobStatusChanged;
uploadJob.OnQueueFinalizeJob += uploadJob_OnQueueFinalizeJob;
uploadJob.Execute();
_uploadJobs.Add(uploadJob);
Logger.LogInfo("New SendLink job added to the upload collection and upload started. JobId = " + uploadJob.Id);
if (JobAdded != null)
{
JobAdded(this, new JobEventArgs() {Job = uploadJob});
}
}
}
示例14: Reparse
private async void Reparse(object sender, FileSystemEventArgs e)
{
if (e != null && e.Name.ToLowerInvariant() != _localFileName)
{
return;
}
var tryCount = 0;
const int maxTries = 20;
while (tryCount++ < maxTries)
{
try
{
var text = File.ReadAllText(_file);
Reparse(text);
break;
}
catch (IOException)
{
}
await Task.Delay(100);
}
await UsageRegistry.ResynchronizeAsync();
if (IsProcessingUnusedCssRules)
{
UnusedCssExtension.All(x => x.SnapshotPage());
}
}
示例15: ChangeWatcher
// When files are created or modified in the "cache" directory, this job will be triggered.
public static void ChangeWatcher(
[FileTrigger(@"cache\{name}", "*.txt", WatcherChangeTypes.Created | WatcherChangeTypes.Changed)] string file,
FileSystemEventArgs fileTrigger,
TextWriter log)
{
log.WriteLine(string.Format("Processed input file '{0}'!", fileTrigger.Name));
}