473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ftpWebResponse fails on alternate calls

I'm getting a list of files from an ftp site using the following method. On
the first call this works perfectly. On the 2nd call, it fails with the
following error. On the 3rd call it succeeds again.

"Failed to list incoming files from ftp site The remote server returned an
error: (550) File unavailable (e.g., file not found, no access)."

I'm guessing that the ftp server thinks the ftpUserID is already connected,
but I don't see any way to disconnect. Any suggestions?

- Jeremy

internal void listFiles(List<stringincomingFiles)
{
FtpWebRequest request =
(FtpWebRequest)WebRequest.Create(ftpPath);
request.UsePassive = false;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(ftpUserID,
ftpPassword);
try
{
FtpWebResponse response =
(FtpWebResponse)request.GetResponse(); <== FAILS HERE.
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);

incomingFiles.Clear();
string file = reader.ReadLine();
while (file != null)
{
incomingFiles.Add(file);
file = reader.ReadLine();
}
reader.Close();
responseStream.Close();//jhg 06/16/2008
response.Close(); //jhg 06/16/2008
}
catch (Exception ex)
{
onProgressEventArgs args = new onProgressEventArgs("Failed
to list incoming files from ftp site " + ex.Message);
showProgress(this, args);
}
}

Jun 27 '08 #1
2 1918
On Jun 16, 2:14 pm, "Jeremy" <jeremy-nos...@ninprodata.comwrote:
I'm getting a list of files from an ftp site using the following method. On
the first call this works perfectly. On the 2nd call, it fails with the
following error. On the 3rd call it succeeds again.

"Failed to list incoming files from ftp site The remote server returned an
error: (550) File unavailable (e.g., file not found, no access)."

I'm guessing that the ftp server thinks the ftpUserID is already connected,
but I don't see any way to disconnect. Any suggestions?

- Jeremy

internal void listFiles(List<stringincomingFiles)
{
FtpWebRequest request =
(FtpWebRequest)WebRequest.Create(ftpPath);
request.UsePassive = false;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(ftpUserID,
ftpPassword);
try
{
FtpWebResponse response =
(FtpWebResponse)request.GetResponse(); <== FAILS HERE.
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);

incomingFiles.Clear();
string file = reader.ReadLine();
while (file != null)
{
incomingFiles.Add(file);
file = reader.ReadLine();
}
reader.Close();
responseStream.Close();//jhg 06/16/2008
response.Close(); //jhg 06/16/2008
}
catch (Exception ex)
{
onProgressEventArgs args = new onProgressEventArgs("Failed
to list incoming files from ftp site " + ex.Message);
showProgress(this, args);
}
}
is the ftp server load balanced? alternate calls succeed could mean
load balancing issue.. where one server does not have the file.
you could use a regular ftp client and connect to the server and see
what happens try it couple of times in a row.

just a thought..
Jun 27 '08 #2
"parez" <ps*****@gmail.comwrote in message
news:db**********************************@k30g2000 hse.googlegroups.com...
>
is the ftp server load balanced? alternate calls succeed could mean
load balancing issue.. where one server does not have the file.
you could use a regular ftp client and connect to the server and see
what happens try it couple of times in a row.
Not load balanced. FileZilla connects consecutively, although it asks
"break current connection?" each time. Interesting suggestion though.

Jeremy

Jun 27 '08 #3

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

Similar topics

3
by: | last post by:
Hi, I have an unmanaged VC7 app calling a C# dotnet service. I'm using the VS2003 generated proxy class derived from CSoapSocketClientT. The client app works fine for most of my customers, but...
15
by: phil-news-nospam | last post by:
This question is borderline between language and programming, but I want to focus more on the language standards issue, rather than the programming issue, so I am posting here. I have a number...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
4
by: sconeek | last post by:
Hi all, I am generating a html based table with multiple rows of data coming in real time from a postgres DB. The underlying technology is java based however the front end is html. now i am...
1
by: Eric Lindsay | last post by:
I am trying to understand the differences between and uses of persistent, default and alternate styles. I have read http://www.w3.org/TR/REC-html40/present/styles.html section 14.3.2 on...
9
by: johkar | last post by:
I need some browser implementation clarification. In the below example, the alternate stylesheet could be invoked by user agents that support alternate stylesheets or by script. Are there any...
1
by: raevian | last post by:
Hi, I have tried using FtpWebResponse however what I am getting is this error: An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The...
1
by: Chris Ashley | last post by:
I'm using FTPWebRequest/FTPWebResponse to access a file over FTP, which I then want to send to the Response.OutputStream. How can I do this? I know I could populate an array of bytes in memory from...
7
by: Jeremy | last post by:
I'm finding very limited number of places where there is a dialog on ftpWebResponse. Can anyone suggest a place to try?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.