使用asp.net的FTP文件上传问题 [英] FTP file upload problem using asp.net

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

问题描述

大家好

我正在尝试使用FtpWebRequest在客户端服务器上上传文件,但是客户端计算机上有防火墙,这会导致问题,我使用的代码是波纹管

Hi All

I am trying to upload a file on clients server using the FtpWebRequest but There is firewall on clients machine which creating problem the code which I used is bellow

// for creating ftp connection
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ConfigurationManager.AppSettings["ftppath"].ToString() + filename);

            // to tell that going to upload file
            request.Method = WebRequestMethods.Ftp.UploadFile;
            // settng the network credentials
            request.Credentials = new NetworkCredential("" + ConfigurationManager.AppSettings["ftpuser"].ToString() + "", "" + ConfigurationManager.AppSettings["ftppass"].ToString() + "");
            // setting passive mode
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = false;
            //request.EnableSsl = true;
            
            // reading file from server which is going to upload
            FileStream stream = File.OpenRead(Server.MapPath(csvpath + filename));
            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            // this line is giving me error since the connection is changed by the NAT firewall due to this I am 
            // getting error 
            // thi line is for uploading the file
            Stream reqStream = request.GetRequestStream();
            reqStream.Write(buffer, 0, buffer.Length);
            reqStream.Close();


我得到的错误是

服务器响应于PASV命令而返回的地址不同于该地址"

如果有人对此有任何想法,请帮助我

谢谢


the error which I am getting is

"The server returned an address in response to the PASV command that is different than the address"

If any body have any idea about this please help me

Thanks

推荐答案

^ ]在这里.


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

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