.NET filesystemwatcher - was it a file or a directory?

后端 未结 4 2061
北恋
北恋 2020-12-05 13:15

Is there a way to determine with the FSW if a file or a directory has been deleted?

4条回答
  •  不知归路
    2020-12-05 13:44

    You could interrogate the FileSystemEventArgs.FullPath property to tell if it is a directory or a file.

    if (Path.GetFileName(e.FullPath) == String.Empty) 
    {
        //it's a directory.
    }
    

    To check if it is a file or directory.

提交回复
热议问题