a529821345 2015-06-09 13:21 采纳率: 0%
浏览 1705

上传ftp出错,刚刚提问写错了,请帮忙

strm = reqFTP.GetRequestStream();
strm.Write(buff, 0, buff.Length);
strm.Dispose();
strm.Close();
到了strm.Dispose();时就报错:
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

  • 写回答

3条回答 默认 最新

  • WorldMobile 2015-06-09 13:38
    关注

    You can use this code to try:

    protected void btnUploadFile_Click(object sender, System.EventArgs e)
    {
    FtpWebRequest myFtpWebRequest;
    FtpWebResponse myFtpWebResponse;
    StreamWriter myStreamWriter;

        myFtpWebRequest = (FtpWebRequest)WebRequest.Create("ftp://ftp_server_name/filename.ext");
    
        myFtpWebRequest.Credentials = new NetworkCredential("username", "password");
    
        myFtpWebRequest.Method = WebRequestMethods.Ftp.UploadFile;
        myFtpWebRequest.UseBinary = true;
    
        myStreamWriter = new StreamWriter(myFtpWebRequest.GetRequestStream());
        myStreamWriter.Write(new StreamReader(Server.MapPath("filename.ext")).ReadToEnd());
        myStreamWriter.Close();
    
        myFtpWebResponse = (FtpWebResponse)myFtpWebRequest.GetResponse();
    
        Response.Write("Upload File Complete, status: " + myFtpWebResponse.StatusDescription);
    
        myFtpWebResponse.Close();
    }
    

    If it is still not work, here is some posts that solved the similar errors. Hope it helps.

    http://nickstips.wordpress.com/2010/10/25/c-ftp-upload-error-the-remote-server-returned-an-error-550-file-unavailable-e-g-file-not-found-no-access/

    http://www.dreamincode.net/forums/topic/76361-file-upload-to-server/

    http://forums.asp.net/t/1374306.aspx/1

    Thanks

    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条