在过去的几个月中,我使用Filesystemwatcher来查找系统中的文件系统更改。但是,当我在GAC中安装程序集时,Filesystemwatcher不会捕获在GAC中注册的dll。这是代码。虽然该文件在位置C:\ Windows \ assembly \ GAC_MSIL \ ConsoleApplication2 \ 1.0.0.0__aea873120d858924 \ consoleapplication2.dll中创建,但我无法在“str”变量中找到该文件。相反,我有它的目录路径。有谁知道它出错的地方。Filesystemwatcher和GAC
static void Main(string[] args)
{
str = new List<string>();
FileSystemWatcher fs = new FileSystemWatcher(@"c:\");
fs.IncludeSubdirectories = true;
fs.Created += new FileSystemEventHandler(OnFileCreate);
fs.Changed += new FileSystemEventHandler(OnFileCreate);
fs.EnableRaisingEvents = true;
new System.EnterpriseServices.Internal.Publish().GacInstall(@"C:\Users\jijiadmin\Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\consoleapplication2.dll");
Console.ReadKey();
}
static void OnFileCreate(object e, FileSystemEventArgs ev)
{
str.Add(ev.FullPath);
}