There is a class for the implementation of FTP client with synchronization.
class FtpFile { private string md5; private string file; private string path; private string status; public string File { get { return file; } set { file = value; } } public string Status { get { return status; } set { status = value; } } public string Md5 { get { return md5; } set { md5 = value; } } public string Path { get { return path; } set { path = value; } }
I want it to go on when I press a button in an infinite loop. I describe the алгоритм
Check file availability. If nobody uses the file, go ahead
Check the md5 file. If it is different, then we will load the file on the server
var listFtpFile = new List<FtpFile>(); FtpFile ftpFile; for (int i = 0; i < dgv.Rows.Count; i++) { ftpFile = new FtpFile(); ftpFile.File = dgv.Rows[i].Cells[1].Value.ToString(); // файл 123.txt ftpFile.Path = dgv.Rows[i].Cells[0].Value.ToString(); // путь / listFtpFile.Add(ftpFile); /* if (Helper.IsFileReady(file)) { var md5 = Helper.CalculateMD5Hash(file); if (ftpFile.Md5 != md5) { ftpFile.Md5 = Helper.CalculateMD5Hash(file); myFTP myFtp = new myFTP(host, login, password, "/"); } } */ }
Now the question is how to correctly implement an infinite loop for Parallel.For
. I do not know, maybe there is a better design just on Thread. Tell me where to swim.