C# WinForm FTP上传批量下载.docxVIP

  • 83
  • 0
  • 约3.14千字
  • 约 3页
  • 2021-11-08 发布于江苏
  • 举报
FTP 上传下载 一:上传单个文件 public void uploadimg() { FileInfo fileInf = new FileInfo(textBox1.Text); //本地要上传的文件路径 //上传的ftp路径+文件名 string uri =@08/images/+textBox1.Text.Substring(textBox1.Text.LastIndexOf(\\)); // 连接FtpWebRequest reqFTP; reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri); reqFTP.UseBinary = true; // 指定数据传输类型 reqFTP.Credentials = new NetworkCredential(imgupload, 123456); // ftp用户名和密码 // 默认为true,连接不会被关闭 // 在一个命令之后被执行reqFTP.KeepAlive = false; // 指定执行什么命令 reqFTP.Method = WebRequestMethods.Ftp.UploadFile; //上传文件时通知服务器文件的大小reqFTP.ContentLength = fileInf.Length; //缓冲大小设置为kb int buffLength = 2048

文档评论(0)

1亿VIP精品文档

相关文档