本文介绍了我该如何修复Webexception?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

public static void UpLoadImage(string source)
        {

            try
            {
                string filename = System.IO.Path.GetFileName(source);
               // string ftpfullpath = ftpurl;
                FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create("ftp://192.168.0.41");
               // ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);

                MessageBox.Show(ftp.GetResponse().ToString());

                ftp.KeepAlive = true;
                ftp.UseBinary = true;
                ftp.Method = WebRequestMethods.Ftp.UploadFile;

                FileStream fs = File.OpenRead(source);
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                fs.Close();

                Stream ftpstream = ftp.GetRequestStream();
                ftpstream.Write(buffer, 0, buffer.Length);
                ftpstream.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }









i want将图像上传到ftp服务器(IIS),但我尝试上传我有这个例外:



发生了'System.Net.WebException'类型的未处理异常



- >例外:请求的URI对此FTP命令无效





如何解决这个问题?





i want to upload image to the ftp server (IIS) but i try to upload i got this exceptions:

An unhandled exception of type 'System.Net.WebException' occurred in

--> The exceptions:The requested URI is invalid for this FTP command


How can i fix this?

推荐答案

FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create("ftp://192.168.0.41/your_file.ext");







如果这有帮助请花时间接受解决方案。谢谢




If this helps please take time to accept the solution. Thank you


这篇关于我该如何修复Webexception?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 18:49