public bool IsVersionDifferent() { // Validate FTP Connection try { var ftpClient = new IPC.Solution.FTPClient(ftpsite, username, password); var remoteversion = ftpClient.directoryListSimple(remoteversionfolder).FirstOrDefault(); DirectoryInfo di = new DirectoryInfo(localversionfolder); if (di.Exists == false) { Directory.CreateDirectory(localversionfolder); } var localversion = Path.GetFileName(System.IO.Directory.GetFiles(localversionfolder).FirstOrDefault()); Console.WriteLine("Remote Version - " + remoteversion); if (localversion == null) { // copy version to local System.IO.File.Create(localversionfolder + remoteversion); return true; } else { if (localversion == remoteversion || remoteversion == "") { return false; // do not Sync } else { // remove old version file System.IO.File.Delete(localversionfolder + localversion); // copy new version file to local folder System.IO.File.Create(localversionfolder + remoteversion); return true; } } } catch (Exception ex) { Console.WriteLine(ex.Message); return false; } }
public SyncFilesManager(string _username, string _password, string _ftpsite, string _localfolder, string _remotefolder, string _syncfolders, string _versionfolder) { username = _username; password = _password; ftpsite = _ftpsite; localfolder = _localfolder; remotefolder = _remotefolder; syncfolders = _syncfolders.Split(';'); versionfolder = _versionfolder; ftpClient = new IPC.Solution.FTPClient(ftpsite, username, password); }
public void Dispose() { ftpClient = null; }