public static bool WaitForFtpReady() { Tools.Log("Start WaitForFtpReady"); var ftpRdy = false; var ftpBsy = false; for (var i = 1; i < 50; i++) { ftpBsy = Ftp.DownloadString("FtpBusy.txt"); ftpRdy = Ftp.DownloadString("FtpReady.txt"); if (ftpRdy == true && ftpBsy == false) { return(true); } else if (ftpRdy == true && ftpBsy == true) { Tools.Report("FtpSync WaitForReady found both 'ready' & 'busy'", new Exception()); FtpDeleteFile("FtpBusy.txt"); } else if (ftpRdy == false && ftpBsy == false) { Tools.Report("FtpSync WaitForReady did not find 'ready' or 'busy'", new Exception()); Ftp.UploadString("FtpReady.txt"); } else { System.Threading.Thread.Sleep(3000); } if (i == 48) { Tools.Report("FtpSync WaitForReady timed out waiting, setting as 'ready'", new Exception()); Ftp.UploadString("FtpReady.txt"); FtpDeleteFile("FtpBusy.txt"); } } Tools.Report("FtpSync error making ready, exited", new Exception()); return(false); }