i'm trying to make a FTP Watcher using WinSCP Library, so i can detect each new file or directory added to a specific path, but not if the uploading of this current file/directory has finished !
Example :
session.Open(sessionOptions);
List < string > prevFiles = null;
while (true) {
// Collect file list
List < string > files =
session.EnumerateRemoteFiles(
remotePath, "*.*", EnumerationOptions.AllDirectories)
.Select(fileInfo => fileInfo.)
.ToList();
if (prevFiles == null) {
// In the first round, just print number of files found
Console.WriteLine("Found {0} files", files.Count);
} else {
// Then look for differences against the previous list
IEnumerable < string > added = files.Except(prevFiles);
if (added.Any()) {
Console.WriteLine("Added files:");
foreach(string path in added) {
Console.WriteLine(path);
}
}
}
prevFiles = files;
Console.WriteLine("Sleeping 10s...");
Thread.Sleep(10000);
}
So my question is how to detect if the uploading of the file has finished, not at the begin of adding a new file in ftp server.