我正在尝试开发一个工具来监视在运行某些Windows驱动程序的安装文件期间生成的文件。我尝试使用简单的代码。 “线程''(0x29e8)已从代码0(0x0)退出。 线程''(0xe3c)已退出,代码为0(0x0)。“
但它只是在控制台中将其作为输出。 我无法获取在目录中创建的文件的更改。请帮忙。
public void StartFileSystemWatcher()
{
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
// Set folder path to watch
fileSystemWatcher.Path = "C:\\";
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.Filter = "*.exe|*.dll|*.ini|*.sys|*.cpl|*.inf|*.pbk|*.cat";
fileSystemWatcher.NotifyFilter = System.IO.NotifyFilters.FileName |
System.IO.NotifyFilters.LastWrite |
System.IO.NotifyFilters.Size |
System.IO.NotifyFilters.DirectoryName;
// Event handlers that are watching for specific event
fileSystemWatcher.Created += new FileSystemEventHandler(fileSystemWatcher_Created);
fileSystemWatcher.Changed += new FileSystemEventHandler(fileSystemWatcher_Changed);
fileSystemWatcher.Deleted += new FileSystemEventHandler(fileSystemWatcher_Deleted);
fileSystemWatcher.Renamed += new RenamedEventHandler(fileSystemWatcher_Renamed);
// START watching
fileSystemWatcher.EnableRaisingEvents = true;
}
void fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File:" + e.ChangeType + " " + e.Name);
}