C# 当新文件添加到Google Drive时,FileSystemWatcher不会收到通知
我正在使用以下代码检查特定文件夹中的新文件/更改,但当我正在检查的文件夹位于Google Drive a中且文件显示在我的文件夹中时,它不会引发事件。在其侦听的文件夹中自己创建文件会引发事件C# 当新文件添加到Google Drive时,FileSystemWatcher不会收到通知,c#,.net,filesystemwatcher,C#,.net,Filesystemwatcher,我正在使用以下代码检查特定文件夹中的新文件/更改,但当我正在检查的文件夹位于Google Drive a中且文件显示在我的文件夹中时,它不会引发事件。在其侦听的文件夹中自己创建文件会引发事件 FileSystemWatcher watcher = new FileSystemWatcher() { Path = Google Drive path, NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
FileSystemWatcher watcher = new FileSystemWatcher() {
Path = Google Drive path,
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
Filter = "*.txt",
EnableRaisingEvents = true
};
watcher.Changed += new FileSystemEventHandler(ActionChecker.FileFound);
这是我的watcher的问题,还是Google Drive的制作方式有问题?正如我所指出的,我应该也在收听watcher.Created
这段代码最初是为Dropbox编写的,Dropbox会创建文件,然后再添加文件内容,但Google Drive的功能有所不同您正在收听的是更改后的事件。如果你想知道新文件已经创建,你当然应该使用created Event!这最初是为Dropbox设计的,Dropbox创建文件,然后附加文件内容。谷歌硬盘似乎在创建后不会对其进行修改。