I create an service that moves files from Linux Computer to Windows by FTPClient. The files in LinuxComputer are generate by an Oracle Store Procedure.
The problem is, I don't know when the files are not being write anymore. Because, first Oracle create the file with 0kb, and then it start writing in it. I add a delayed to get the file, but it is not the solution.
FTP Connection
FluentFTP.FtpClient originClient = new FluentFTP.FtpClient(FTPOriginHost, FTPOriginUser, FTPOriginPass);
originClient.Connect();
Log.Info("FTP client is Connected.");
originClient.GetWorkingDirectoryAsync().ContinueWith(d => Log.Info(d.Result));
originClient.SetWorkingDirectoryAsync(FTPOriginPath).Wait();
originClient.GetWorkingDirectoryAsync().ContinueWith(d => Log.Info(d.Result)).Wait();
return originClient;
Download
originClient.GetListingAsync(FTPOriginPath).ContinueWith(t =>
{
foreach (var item in t.Result)
{
originClient.DownloadFileAsync(DestinationPath + item.Name, item.FullName, true).ContinueWith(tt =>
{
Log.Info(item.Name + " DOWNLOAD: OK");
}, System.Threading.Tasks.TaskContinuationOptions.OnlyOnRanToCompletion).Wait();
}
}, System.Threading.Tasks.TaskContinuationOptions.OnlyOnRanToCompletion).Wait();
I thougth in moving file to another copy, to check if it is being copy or not, but if I move file, to another folder in Linux while it is being write, it is move ok, and continue being write ok in the other folder so it does not work.e