名称WebRequestMethods在当前上下文中不存在,并且找不到FTPWebResopnce

时间:2014-11-18 12:33:23

标签: c#

我正在为文件下载做编码但是WebRequestMethods不存在显示..

        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://something.com/temp.exe");
        request.Method = WebRequestMethods.Ftp.DownloadFile;

        request.Credentials = new NetworkCredential("admin", "1234");

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();

        Stream responseStream = response.GetResponseStream();
        FileStream file = File.Create(@"c:\temp\temp.exe");
        byte[] buffer = new byte[32 * 1024];
        int read;
        //reader.Read(

        while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0)
        {
            file.Write(buffer, 0, read);
        }

        file.Close();
        responseStream.Close();
        response.Close();

以上是我的代码,请指导我。!

1 个答案:

答案 0 :(得分:0)

请考虑引用System程序集并在代码中添加System.Mail命名空间。

修改: - .NET Compact框架不支持System.Net.Mail或System.Web.Mail。你应该寻找扩展。