我试图了解是否在给定目录中创建了新文件。我有下一个代码:
private static void CreateWatcher()
{
//Create a new FileSystemWatcher.
FileSystemWatcher watcher = new FileSystemWatcher();
//Set the filter to all files.
watcher.Filter = "*.*";
//Subscribe to the Created event.
watcher.Created += new FileSystemEventHandler(watcher_FileCreated);
//Set the path
watcher.Path = path;
//Enable the FileSystemWatcher events.
watcher.EnableRaisingEvents = true;
}
private static void watcher_FileCreated(object sender, FileSystemEventArgs e)
{
Console.WriteLine("Nuevo archivo creado -> " + e.Name);
}
public static void Main(string[] args)
{
CreateWatcher();
CreateFiles();
Console.Read();
}
In" CreatedFiles()"功能,我在路径上创建3个新文件(1个zip和2个txt)。它检测到我的2个txt文件,但与zip文件不一样。我该如何解决?
谢谢!