473,586 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FTPWebRequest Problem

If I create an MFC application in Visual Studio 6 using the following code:

CInternetSessio n inet_session;
CFtpConnection *ftp_connection ;

ftp_connection = inet_session.Ge tFtpConnection( "Integration300 ", "guest",
"ihannah", 21,TRUE);

CString CurrentDirector y;
ftp_connection->GetCurrentDire ctory(CurrentDi rectory);

then the FTP connection is made and works as expected.

If I then try and use the following code (C#, Visual Studio 2005) I always
get a timeout:

// Get the object used to communicate with the server.
FtpWebRequest request =
(FtpWebRequest) WebRequest.Crea te(@"ftp://integration300" );
request.Credent ials = new NetworkCredenti al("guest","iha nnah");
request.Proxy = null;
request.EnableS sl = false;
request.UseBina ry = true;
request.KeepAli ve = false;
request.Method = WebRequestMetho ds.Ftp.ListDire ctoryDetails;

FtpWebResponse response = (FtpWebResponse )request.GetRes ponse();
response.Close( );

Does anyone have any idea why this is the case?

Regards

--
Ian H
Sep 11 '06 #1
2 7922
Ian,

You are specifying passive mode in the call to GetFtpConnectio n. For
the FtpWebRequest class, you should set the UsePassive property to true so
that you make the connection to the server, and not the other way around
(you are probably behind a firewall, which is why it didn't work).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ian Hannah" <Ia*******@disc ussions.microso ft.comwrote in message
news:0E******** *************** ***********@mic rosoft.com...
If I create an MFC application in Visual Studio 6 using the following
code:

CInternetSessio n inet_session;
CFtpConnection *ftp_connection ;

ftp_connection = inet_session.Ge tFtpConnection( "Integration300 ", "guest",
"ihannah", 21,TRUE);

CString CurrentDirector y;
ftp_connection->GetCurrentDire ctory(CurrentDi rectory);

then the FTP connection is made and works as expected.

If I then try and use the following code (C#, Visual Studio 2005) I always
get a timeout:

// Get the object used to communicate with the server.
FtpWebRequest request =
(FtpWebRequest) WebRequest.Crea te(@"ftp://integration300" );
request.Credent ials = new NetworkCredenti al("guest","iha nnah");
request.Proxy = null;
request.EnableS sl = false;
request.UseBina ry = true;
request.KeepAli ve = false;
request.Method = WebRequestMetho ds.Ftp.ListDire ctoryDetails;

FtpWebResponse response = (FtpWebResponse )request.GetRes ponse();
response.Close( );

Does anyone have any idea why this is the case?

Regards

--
Ian H

Sep 11 '06 #2

Nicholas,

Thanks for the reply. In the call to GetFtpConnectio n it does not
matter if I pass TRUE or FALSE in as the final parameter - it always
works.

Likewise with the C# code setting UsePassive makes no different - it
still doesn't work.

Ian

Nicholas Paldino [.NET/C# MVP] wrote:
Ian,

You are specifying passive mode in the call to GetFtpConnectio n. For
the FtpWebRequest class, you should set the UsePassive property to true so
that you make the connection to the server, and not the other way around
(you are probably behind a firewall, which is why it didn't work).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ian Hannah" <Ia*******@disc ussions.microso ft.comwrote in message
news:0E******** *************** ***********@mic rosoft.com...
If I create an MFC application in Visual Studio 6 using the following
code:

CInternetSessio n inet_session;
CFtpConnection *ftp_connection ;

ftp_connection = inet_session.Ge tFtpConnection( "Integration300 ", "guest",
"ihannah", 21,TRUE);

CString CurrentDirector y;
ftp_connection->GetCurrentDire ctory(CurrentDi rectory);

then the FTP connection is made and works as expected.

If I then try and use the following code (C#, Visual Studio 2005) I always
get a timeout:

// Get the object used to communicate with the server.
FtpWebRequest request =
(FtpWebRequest) WebRequest.Crea te(@"ftp://integration300" );
request.Credent ials = new NetworkCredenti al("guest","iha nnah");
request.Proxy = null;
request.EnableS sl = false;
request.UseBina ry = true;
request.KeepAli ve = false;
request.Method = WebRequestMetho ds.Ftp.ListDire ctoryDetails;

FtpWebResponse response = (FtpWebResponse )request.GetRes ponse();
response.Close( );

Does anyone have any idea why this is the case?

Regards

--
Ian H
Sep 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3538
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP host is on a Unix server. I'm using the FtpWebRequest and FtpWebResponse classes to do the file uploading. I have tested it without any errors at all...
7
16207
by: jose.lopes.cruz | last post by:
I need to access a FTP Server. I'm using FTPWebRequest as described in visual studio 2005 documentation. Everything works fine except the following: 1) I dont know how to change de current working directory on the server to the parent directory? 2) Why cant I do this, or why doesn't work? In Internet explorer works! <some code...for...
2
10325
by: Ian Hannah | last post by:
I am running the following code (using VS 2005) with the appropriate username and password and the request always timeouts: FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://integration300:20/"); request.Method = WebRequestMethods.Ftp.ListDirectory; request.UsePassive = false; request.Credentials = new...
0
1343
by: Bob Phillips | last post by:
Hello All: I've seen some strange behavior with the .net FtpWebRequest component. static void Main(string args) { Console.WriteLine("Connecting to server to list directory..."); Uri uri = new Uri("ftp://192.168.0.3/data/"); FtpWebRequest listRequest =
3
9711
by: Kevien Lee | last post by:
hi everyone I have a quick question when i use the FtpWebRequest. What I need to do is that: Connect a FTP server,check whether there is a folder if not,create it, then changed the path to the new folder If use the command line to do that,it just use the "CD" command can finish.But there is not the command in WebRequestMethods.Ftp
0
9787
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
5
7677
by: Sendil kumar | last post by:
Hi All, The FtpWebRequest.GetResponse( ) method is not giving "550 File not found exception " when I do a directory list operation on a invalid(not present) directory in HP Unix and Sun Solaris system, but the same is working fine in windows. For example, this is my uri to connect to the Sun Solaris server machine...
9
3896
by: Waldy | last post by:
Hi there, I have written a service in VS2005 that downloads files from an FTP site processes them and then deletes the files if successfully processed. It all works fine when run in our test lab with an FTP site that I setup on IIS. However, I have an issue at the customer site. Their FTP server is on Linux, but I presume that is not an...
6
13672
by: Patrick.Simons | last post by:
I try to connect a FTPWebRequest through Proxy and VPN to a remote FTP- server. Sometimes it works sometimes not. When my VB.Net-App (2005) returns the error on the GetResponse-Method, I'll try to use the Windows Explorer to go on the FTP-URI and this always works. So the problem should come from my app. my simplified code: Private...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.