从FTP下载文件 [英] Download Files From FTP

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

问题描述



Hi,

String remoteUri = "ftp://myftp/";
String fileName = "11187368121flynn1.doc", myStringWebResource = null;
WebClient myWebClient = new WebClient();
myWebClient.Credentials = new NetworkCredential("*****","*****");
myStringWebResource = remoteUri + fileName;
myWebClient.DownloadFile(myStringWebResource, fileName);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);


我正在尝试从FTP下载文件.上面的代码在VS 2005和2008中工作正常,但在VS 2003中不工作.

我想在VS 2003中执行此操作,因为我们的项目中存在一些约束.请问有人可以帮忙吗?

谢谢,
Prasant


I am trying to download files from FTP. The above code is working fine in VS 2005 and 2008 but it''s not working in VS 2003.

I want to do this in VS 2003 because there are some constraints in our project. Can any one help on this please?

Thanks,
Prasant

推荐答案

嗨Prasant,

我有一些不愉快的消息给你. .NET 1.1 WebClient没有对FTP的内置支持,而FTPWebRequest仅在.NET 2.0中引入.您的代码应引发不支持"异常.
您将必须在网上搜索以查看是否可以找到.NET 1.1的FTP实现.

对不起. :((

修改:
刚刚在CP上找到了它,也许会成功,请检查一下:
http://www.codeproject.com/KB/IP/ftpclientclass.aspx [ ^ ]

祝你好运!

曼弗雷德(Manfred)
Hi Prasant,

I have some unpleasant news for you. .NET 1.1 WebClient has no build in support for FTP and FTPWebRequest was only introduced in .NET 2.0. Your code should throw a "not supported" exception.
You will have to search the net to see if you can find an FTP implementation for .NET 1.1 .

I''m sorry. :((

Modification:
Just found this here on CP maybe it''ll do, please check it out:
http://www.codeproject.com/KB/IP/ftpclientclass.aspx[^]

Good luck!

Manfred


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

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