使用FTP上传文件 [英] File Upload with FTP

查看:112
本文介绍了使用FTP上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在c#中将文件上传到ftp。在上传时给我这个错误。

无法使用此动词类型发送内容正文。以下是我的代码



  private   void  btnUpload_Click( object  sender,EventArgs e)
{

// 加载文件
string filePath = txtFileName.Text ;
FileStream stream = File.OpenRead(filePath);
byte [] buffer = new byte [stream.Length];

stream.Read(buffer, 0 ,buffer.Length);
stream.Close();

// 上传文件
流reqStream = request.GetRequestStream (); // 请求全局声明
reqStream.Write(buffer, 0 ,buffer.Length);
reqStream.Close();

MessageBox.Show( 上传成功);


}

解决方案

这是一个非常好的代码片段:< br $> b $ b

http://www.digitalcoding.com/Code-Snippets/C-Sharp/C-Code-Snippet-Upload-file-to-FTP-Server.html [ ^ ]

Hi,
I need to upload a file to ftp in c#. While uploading its giving me this error.
Cannot send a content-body with this verb-type. Below is my code

private void btnUpload_Click(object sender, EventArgs e)
       {

           //Load the file
           string filePath = txtFileName.Text;
           FileStream stream = File.OpenRead(filePath);
           byte[] buffer = new byte[stream.Length];

           stream.Read(buffer, 0, buffer.Length);
           stream.Close();

           //Upload file
           Stream reqStream = request.GetRequestStream();//request is declared globally
           reqStream.Write(buffer, 0, buffer.Length);
           reqStream.Close();

           MessageBox.Show("Uploaded Successfully");


       }

解决方案

This is a really good code snippet:

http://www.digitalcoding.com/Code-Snippets/C-Sharp/C-Code-Snippet-Upload-file-to-FTP-Server.html[^]


这篇关于使用FTP上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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