Search code examples
c#.netfilesystemwatcher

FileSystemWatcher does not get notified when a new file is added to Google Drive


I'm using the following code to check for a new file/change in a specific folder, but it doesn't raise an event when the folder I am checking for is in Google Drive alouth the file shows up in my folder. Creating a file myself in the folder it listens to does raise an event.

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);

Is this a problem with my watcher, or the way Google Drive is made?


Solution

  • As Steve pointed out, I should be listening for watcher.Created as well.

    The code was originally intended for Dropbox, which creates the file and after that appends the file-content, but Google Drive does things differently