Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1161
  • Last Modified:

FTP Client with FtpWebRequest

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
andre72
Asked:
andre72
  • 2
  • 2
2 Solutions
 
andre72Author Commented:
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
 
Dhanasekaran SengodanCommented:
i have a query, r u upload something in server?
0
 
andre72Author Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now