473,804 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FtpWebRequest DeleteFile Problem

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 issue. What happened the
first time I ran it was that it deleted every other file. It just so
happened that there were files of about 60k and files of about 600k. The
small files were deleted, but the large ones were not. A WebException error
occured for the second, fourth e.t.c. files. When I ran it again, only the
larger files were left in the FTP folder, and only the first one was
deleted. I guess it may be sone sort of timing issue..
Aug 29 '08 #1
9 3903
On Aug 29, 5:38*am, "Waldy" <some...@micros oft.comwrote:
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 sitethat
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 issue. *What happened the
first time I ran it was that it deleted every other file. *It just so
happened that there were files of about 60k and files of about 600k. *The
small files were deleted, but the large ones were not. *A WebException error
occured for the second, fourth e.t.c. files. *When I ran it again, onlythe
larger files were left in the FTP folder, and only the first one was
deleted. *I guess it may be sone sort of timing issue..
what says the exception?
Can you delete those files if you connect from the system ftp? maybe
you do not have permission to delete them
Aug 29 '08 #2

"Waldy" <so*****@micros oft.comwrote in message
news:u%******** ********@TK2MSF TNGP03.phx.gbl. ..
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 issue. What happened the
first time I ran it was that it deleted every other file. It just so
happened that there were files of about 60k and files of about 600k. The
small files were deleted, but the large ones were not. A WebException
error
occured for the second, fourth e.t.c. files. When I ran it again, only
the
larger files were left in the FTP folder, and only the first one was
deleted. I guess it may be sone sort of timing issue..

Can you please check exact exception? Is it maybe "bad sequence of
commands"?

Regards,
Goran
Sep 1 '08 #3

"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:eK******** ******@TK2MSFTN GP06.phx.gbl...
Can you please check exact exception? Is it maybe "bad sequence of
commands"?
Hi Goran,
here is the error:

Exception: System.Net.WebE xception
Message: The remote server returned an error: (500) Syntax error, command
unrecognized.
Source: System
at System.Net.FtpW ebRequest.SyncR equestCallback( Object obj)
at System.Net.FtpW ebRequest.Reque stCallback(Obje ct obj)
at System.Net.Comm andStream.Abort (Exception e)
at System.Net.FtpW ebRequest.Finis hRequestStage(R equestStage stage)
at System.Net.FtpW ebRequest.GetRe sponse()
Sep 2 '08 #4
"Waldy" <so*****@micros oft.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>
"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:eK******** ******@TK2MSFTN GP06.phx.gbl...
>Can you please check exact exception? Is it maybe "bad sequence of
commands"?

Hi Goran,
here is the error:

Exception: System.Net.WebE xception
Message: The remote server returned an error: (500) Syntax error, command
unrecognized.
Source: System
at System.Net.FtpW ebRequest.SyncR equestCallback( Object obj)
at System.Net.FtpW ebRequest.Reque stCallback(Obje ct obj)
at System.Net.Comm andStream.Abort (Exception e)
at System.Net.FtpW ebRequest.Finis hRequestStage(R equestStage stage)
at System.Net.FtpW ebRequest.GetRe sponse()
It might help if you use a packet sniffer to get the actual log of the FTP
session - what commands go to the server, and what the responses to each
are.
Sep 2 '08 #5

"Pavel Minaev" <in****@gmail.c omwrote in message
news:es******** ******@TK2MSFTN GP05.phx.gbl...
"Waldy" <so*****@micros oft.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..

"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:eK******** ******@TK2MSFTN GP06.phx.gbl...
Can you please check exact exception? Is it maybe "bad sequence of
commands"?
Hi Goran,
here is the error:

Exception: System.Net.WebE xception
Message: The remote server returned an error: (500) Syntax error,
command
unrecognized.
Source: System
at System.Net.FtpW ebRequest.SyncR equestCallback( Object obj)
at System.Net.FtpW ebRequest.Reque stCallback(Obje ct obj)
at System.Net.Comm andStream.Abort (Exception e)
at System.Net.FtpW ebRequest.Finis hRequestStage(R equestStage stage)
at System.Net.FtpW ebRequest.GetRe sponse()

It might help if you use a packet sniffer to get the actual log of the FTP
session - what commands go to the server, and what the responses to each
are.

Yes, sniffer should reveal the problem. I had similar problem with UNIX
based system and FTPWebRequest. FTPWebRequest is cacheing connections to FTP
server and reuses the connection between commands. However, it resend
USER/PASS commands even on already connected and authorized connection (and
that is allowed according to standard) and UNIX server refuses it (it's an
embedded system). I end up with "bad sequence of commands", which is bit
different than what original poster gets.

Wireshark is free and powerfull sniffer, if we see the trace I guess will
find the problem.

Regards,
Goran
Sep 2 '08 #6
"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:O3******** *****@TK2MSFTNG P05.phx.gbl...
Yes, sniffer should reveal the problem. I had similar problem with UNIX
based system and FTPWebRequest. FTPWebRequest is cacheing connections to
FTP
server and reuses the connection between commands. However, it resend
USER/PASS commands even on already connected and authorized connection
(and
that is allowed according to standard) and UNIX server refuses it (it's an
embedded system). I end up with "bad sequence of commands", which is bit
different than what original poster gets.
Hi Goran,
according to the trace, the response is returning 500
Unknown Command from a User request. So it appears to be the problem that
you talked about. How did you get round it.
Sep 3 '08 #7

"Waldy" <so*****@micros oft.comwrote in message
news:u6******** ******@TK2MSFTN GP03.phx.gbl...
"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:O3******** *****@TK2MSFTNG P05.phx.gbl...
>Yes, sniffer should reveal the problem. I had similar problem with UNIX
based system and FTPWebRequest. FTPWebRequest is cacheing connections to
FTP
server and reuses the connection between commands. However, it resend
USER/PASS commands even on already connected and authorized connection
(and
that is allowed according to standard) and UNIX server refuses it (it's
an
embedded system). I end up with "bad sequence of commands", which is bit
different than what original poster gets.

Hi Goran,
according to the trace, the response is returning 500
Unknown Command from a User request. So it appears to be the problem that
you talked about. How did you get round it.
Hi,
I gave up FTPWebRequest.. . Found some ugly FTP client code on the internet,
fixed few bugs and it's working now. You may try to set keepalive to false,
however that has some side effects (reconnect on every command).

Regards,
Goran

Sep 3 '08 #8

"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:Or******** ******@TK2MSFTN GP06.phx.gbl...
>
You may try to set keepalive to false, however that has some side effects
(reconnect on every command).

Regards,
Goran
Good man! That's fixed it for me.
Sep 4 '08 #9

"Waldy" <so*****@micros oft.comwrote in message
news:uY******** ******@TK2MSFTN GP06.phx.gbl...
>
"Goran Sliskovic" <gs******@yahoo .comwrote in message
news:Or******** ******@TK2MSFTN GP06.phx.gbl...

You may try to set keepalive to false, however that has some side effects
(reconnect on every command).

Regards,
Goran

Good man! That's fixed it for me.

Keep in mind that this will (probably) open/close TCP connection for every
command. If you have lot of commands (eg. files to delete) this is not free.
It will depend on the network infrastructure/project you are working on
whether this turns to real problem. You could possibly be cut by routers in
between as a result of false attack detection in some cases. It sucked for
me (connecting to embedded system over slow/high latency links). It is
relativly cheap to create interface and allow implementation to change. But
that depends on your project requirements.

Regards,
Goran
Sep 4 '08 #10

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

Similar topics

0
3573
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 uploading to an IIS FTP server hosted on our network Most of the time it uploads without error to...
7
16223
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 FtpWebRequest>
2
10336
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 NetworkCredential(<user>,<password>); request.Proxy = null;
0
1352
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
9719
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
9803
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
7696
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 "ftp://ssriniva:ssriniva@apfsun/apfqa/users/ssriniva/apfhome/config" here the 'config' folder is not present in the...
1
1765
by: rupan | last post by:
Getting ERROR: The remote name could not be resolved? why? ************************************************************************************** Try Dim reqUri As String reqUri = "ftp://domeinname.com" Dim req As FtpWebRequest = CType(WebRequest.Create(reqUri), FtpWebRequest)
6
13694
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 m_oFTP As FtpWebRequest Private oResponseDir As FtpWebResponse = Nothing
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2997
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.