Solved

FTP Client with FtpWebRequest

Posted on 2010-08-18
5
1,016 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel file not created as expected 7 50
ADO.NET ENTITY DATA MODEL 3 31
Name space syntax error 12 43
Web Form VB.Net  import CSV 4 26
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now