Solved

FTP Client with FtpWebRequest

Posted on 2010-08-18
5
1,039 Views
Last Modified: 2013-12-17
Hi,

I have a small command tool we use to get some data from a FTP server.
The matter is that the network is now after a proxy server and to connect to the FTP server the proxy mode is USER@HOST.
I found some samples to connect with this using a socket but no sample how to connect to using FtpWebRequest.
As I don't change the whole class I would prefer this way to connect ...

Is there a way how to do?

Thanks

Andre
//create request
FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
//Set the login details
result.Credentials = Credentials;//GetCredentials();
//Do not keep alive (stateless mode)
result.KeepAlive = true;

// Set Proxy if need for
IWebProxy wp=null;
if (!String.IsNullOrEmpty(Proxy))
{
    if (String.IsNullOrEmpty(Port))
        wp = new WebProxy(Proxy);
    else
        wp = new WebProxy(Proxy,int.Parse(Port));

    if (!String.IsNullOrEmpty(ProxyUsername))
        wp.Credentials = ProxyCredentials;
}
result.Proxy = wp;
result.UsePassive = true;

Open in new window

0
Comment
Question by:andre72
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 250 total points
ID: 33463365
0
 
LVL 14

Assisted Solution

by:Dhanasekaran Sengodan
Dhanasekaran Sengodan earned 250 total points
ID: 33463901
0
 

Author Comment

by:andre72
ID: 33463904
Thanks, this is very simular to my function and this worked fine before there was a proxy installed.
Now I can access using FF like ftp://user:pw@domain/file but what ever I try now from my client it can't connect.
Is there a way to trace FTP like fiddler for HTTP?
0
 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 33464244
i have a query, r u upload something in server?
0
 

Author Comment

by:andre72
ID: 33464958
No uploads, just DL.

I figured out that WebClient request = new WebClient(); seems to work with the proxy settings so it works fine now. Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question