![](/img/trans.png)
[英]WinSCP.SessionRemoteException: Copying files to remote side failed. Could not change to “/ftp:/”; 'ftp:' not found
[英]Compare local and remote files on FTP with WinSCP lib
如何使用 .NET 在 FTP 服务器上通过 WinSCP 检查更新?
我正在使用SynchronizationMode.Local
例如:
if(have_new_update){
MessageBox("U can update")
if(ok){
update();
}
}else{
return;
}
我的代码:
SessionOptions sessionOptions = new SessionOptions {
Protocol = Protocol.Ftp, HostName = ftp_url, UserName = username, Password = pass
};
using (Session session = new Session()) {
rtb_update_material.AppendText("\nConnected\n");
//Transferring
session.FileTransferred += FileTransferred;
session.FileTransferProgress += SessionProgressBar;
session.Open(sessionOptions);
SynchronizationResult synchronizationResult;
synchronizationResult = session.SynchronizeDirectories(SynchronizationMode.Local, @"MyPath\", "/", true);
synchronizationResult.Check();
if (synchronizationResult.IsSuccess)
rtb_update_material.AppendText("Done\n");
使用Session.CompareDirectories
查找本地和远程目录之间的差异:
var diffs =
session.CompareDirectories(SynchronizationMode.Remote, localPath, remotePath, false);
if (diffs.Count > 0)
{
// there are differences
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.