Hi,
string remoteUri = ftp://myftp;
string fileName = "11187368121flynn1.doc", myStringWebResource = null;
WebClient myWebClient = new WebClient();
myWebClient.Credentials = new NetworkCredential("*****","*****");
myStringWebResource = remoteUri + fileName;
// Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
myWebClient.DownloadFile(myStringWebResource, fileName);
// Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);
I am trying to download files from ftp.The above code is working fine in VS 2005 and 2008,But its not working in VS 2003.and i wanted to do in VS 2003.Because there are some constraints in our project.We need to do in VS 2003.Can any one help on this plz...
Thanks,
Prasant


Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 28, 2010, 6:12 AM EST
For more details, look at the following link
http://www.devasp.net/net/articles/display/280.html
Prasant JinagaRank #2,383 · 594 reputationPosted Dec 28, 2010, 5:51 PM EST
Thanks,
Prasant
thiago costaRank #6,113 · 276 reputationPosted Dec 28, 2010, 8:22 PM EST
I haven't tested it with ftp but might work..
using System.Net;
WebClient Client = new WebClient();
Client.DownloadFile("ftp://2.2.1.1/file.zip", "file.zip");
----EDIT---
Ohhhh, I just read this from our mate :
FtpWebRequest class instead of WebClient
I think he is right.
did you add
using System.Net;
webclient depends on it.
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 28, 2010, 8:24 PM EST
Prasant JinagaRank #2,383 · 594 reputationPosted Dec 28, 2010, 9:07 PM EST
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 28, 2010, 10:27 PM EST
The FtpWebRequest class is in System.Net namespace. Check it from Object Explorer.
It should work....
Prasant JinagaRank #2,383 · 594 reputationPosted Dec 28, 2010, 11:05 PM EST
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 28, 2010, 11:13 PM EST
Workaround is to use some third party component like
http://www.codeproject.com/KB/IP/ftplib.aspx
Be aware before using it. Go through the codebase before putting it in production since it is third party open source component. Use that one and see if it works fine for you!!!
Prasant JinagaRank #2,383 · 594 reputationPosted Dec 29, 2010, 12:09 AM EST