通过安全套接字层访问远程ftp [英] accessing Remote ftp over a secure socket layer

查看:70
本文介绍了通过安全套接字层访问远程ftp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关通过互联网连接两个远程服务器以共享文件并同步它们的帮助.系统应该至少平衡两个服务器上的文件.如果您知道我可以用来实现此目标的任何示例c#或vb.net,请提出建议.

I need help with connection two remote severs over the internet to share files and sync them. The system is supposed to balance the file on both servers at least fast. Please if you know any sample c# or vb.net that I can use to achieve this please advice.

推荐答案

下面的代码是如何使用ssl上传文件. EnableSSL = true;这就是您要找的东西吗?

The code below is how to upload a file using ssl. EnableSSL = true; is this what you were looking for?

private NetworkCredential FtpLogin()
{
    return new NetworkCredential(FtpUser, FtpPass);
}

public void Put(string filename)
{
            FtpWebRequest requestFTPUploader = (FtpWebRequest)WebRequest.Create(string.Format(@"{0}/{1}", FtpServer, Path.GetFileName(filename)));
            requestFTPUploader.Credentials = FtpLogin();
            requestFTPUploader.Method = WebRequestMethods.Ftp.UploadFile;
            requestFTPUploader.EnableSsl = true;
            //---------------------
            FileInfo fileInfo = new FileInfo(filename);
            FileStream fileStream = fileInfo.OpenRead();
            //---------------------
            int bufferLength = 2048;
            byte[] buffer = new byte[bufferLength];
            //---------------------
            Stream uploadStream = requestFTPUploader.GetRequestStream();
            int contentLength = fileStream.Read(buffer, 0, bufferLength);
            //---------------------
            while (contentLength != 0)
            {
                uploadStream.Write(buffer, 0, contentLength);
                contentLength = fileStream.Read(buffer, 0, bufferLength);
            }
            //---------------------
            uploadStream.Close();
            fileStream.Close();
            //---------------------
            requestFTPUploader = null;
}//END Upload


这篇关于通过安全套接字层访问远程ftp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆