Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FTP Client with FtpWebRequest

Posted on 2010-08-18
5
Medium Priority
?
1,130 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

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

Assisted Solution

by:Dhanasekaran Sengodan
Dhanasekaran Sengodan earned 1000 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

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.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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