FTPWEBRequest always return error 550

E

Edison.CCC

I'm facing a prblem with FTPWebRequest of .NET v2.0
1. The FTP server I have to access is a small device(not a PC)
which provides 2 folders named c: & d:. While attempting to
access/get/put files I always get the following exception
System.Net.WebException: The remote server returned an error: (550)
File unavail
able (e.g., file not found, no access).
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at ConsoleApplication1.Program.Main(String[] args)

Can anyone provide some pointers/ideas? Other FTP client softwares
like WS-FTP are able to connect
and down/upload without any issues to that server.

Thanks in advance,
Ed.
I have provided my code snippet below for your reference -

Private Sub Download(ByVal downloadUrl As String)
Dim responseStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim reader As StreamReader = Nothing
Try
Dim downloadRequest As FtpWebRequest = _
WebRequest.Create(downloadUrl)

downloadRequest.Proxy = Nothing
downloadRequest.UsePassive = True
downloadRequest.UseBinary = True

downloadRequest.Credentials = New _
System.Net.NetworkCredential("xx", "xx")

Dim downloadResponse As FtpWebResponse = _
downloadRequest.GetResponse()

responseStream = downloadResponse.GetResponseStream()

Dim fileName As String = _

Path.GetFileName(downloadRequest.RequestUri.AbsolutePath)

If fileName.Length = 0 Then
reader = New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())
Else
fileStream = File.Create(fileName)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = responseStream.Read(buffer, 0,
buffer.Length)
If bytesRead = 0 Then
Exit While
End If
fileStream.Write(buffer, 0, bytesRead)
End While
End If
Console.WriteLine(downloadResponse.StatusCode & " " &
downloadResponse.StatusDescription)
Console.WriteLine("Download complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
ElseIf responseStream IsNot Nothing Then
responseStream.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
End Try
End Sub
 
P

Patrick Steele

I'm facing a prblem with FTPWebRequest of .NET v2.0
1. The FTP server I have to access is a small device(not a PC)
which provides 2 folders named c: & d:. While attempting to
access/get/put files I always get the following exception
System.Net.WebException: The remote server returned an error: (550)
File unavail
able (e.g., file not found, no access).
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at ConsoleApplication1.Program.Main(String[] args)

Can anyone provide some pointers/ideas? Other FTP client softwares
like WS-FTP are able to connect
and down/upload without any issues to that server.

I would use TcpTrace (http://www.pocketsoap.com/tcptrace/) and monitor
the traffic from .NET's FTPWebRequest as well as WS-FTP and make sure
they're sending the same FTP commands.
 
E

Edison.CCC

I used ethereal and found that the error was due to FtpWebRequest
transmitting an erroneous command- CWD c:\/c:/

Is there a way to correct this?
Thanks in advance,
Edison

Patrick said:
I'm facing a prblem with FTPWebRequest of .NET v2.0
1. The FTP server I have to access is a small device(not a PC)
which provides 2 folders named c: & d:. While attempting to
access/get/put files I always get the following exception
System.Net.WebException: The remote server returned an error: (550)
File unavail
able (e.g., file not found, no access).
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at ConsoleApplication1.Program.Main(String[] args)

Can anyone provide some pointers/ideas? Other FTP client softwares
like WS-FTP are able to connect
and down/upload without any issues to that server.

I would use TcpTrace (http://www.pocketsoap.com/tcptrace/) and monitor
the traffic from .NET's FTPWebRequest as well as WS-FTP and make sure
they're sending the same FTP commands.
 
P

Patrick Steele

I used ethereal and found that the error was due to FtpWebRequest
transmitting an erroneous command- CWD c:\/c:/

Is there a way to correct this?

Not sure. I'm not really impressed with the FTP classes in .NET 2.0:

http://tinyurl.com/2q7kxy

What's the full URI you're using?
 
E

Edison.CCC

Not sure. I'm not really impressed with the FTP classes in .NET 2.0:

http://tinyurl.com/2q7kxy

What's the full URI you're using?


My url is ftp://aa.bb.cc.dd/c:/TextFile.txt.
I have also tried with ftp://aa.bb.cc.dd/c%3A/TextFile.txt.

Regret that I cannot share the IP address part of the URL.

Is there a workaround for this apart from having an implementation
using Sockets?

Thanks in advance,
Ed
 
P

Patrick Steele

My url is ftp://aa.bb.cc.dd/c:/TextFile.txt.

I'm not even sure that's a valid URI for FTP. FTP servers don't have
the concept of drive letters. You just connect to a site that has files
and folders. I'm surprised that it worked in WS-FTP.
 
E

Edison.CCC

Patrick said:
I'm not even sure that's a valid URI for FTP. FTP servers don't have
the concept of drive letters. You just connect to a site that has files
and folders. I'm surprised that it worked in WS-FTP.

I created a directory with name as "c:" in a Linux and my app was able
to FTP to that directory without any problems.
So I think it is not a problem of ":" in the URL.
It seems to point to an internal problem in .NETv2 's FTPWebRequest
class

Is there a workaround for that?

Thanks in advance,
Ed
 
P

Patrick Steele

I created a directory with name as "c:" in a Linux and my app was able
to FTP to that directory without any problems.
So I think it is not a problem of ":" in the URL.
It seems to point to an internal problem in .NETv2 's FTPWebRequest
class

Is there a workaround for that?

Not that I know of. There's a bunch of free FTP source code out there
that would probably eliminate this problem.
 
G

Guest

I got same issue, and it took me a few hrs to figure it out.
After trying a few things, thought of permission. So I went to properties of
the ftp, checked "Write" permission checkbox under Home Security tab, no more
error. By the way, I was trying to upload. Hope this may help.

william


I'm facing a prblem with FTPWebRequest of .NET v2.0
1. The FTP server I have to access is a small device(not a PC)
which provides 2 folders named c: & d:. While attempting to
access/get/put files I always get the following exception
System.Net.WebException: The remote server returned an error: (550)
File unavail
able (e.g., file not found, no access).
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at ConsoleApplication1.Program.Main(String[] args)

Can anyone provide some pointers/ideas? Other FTP client softwares
like WS-FTP are able to connect
and down/upload without any issues to that server.

Thanks in advance,
Ed.
I have provided my code snippet below for your reference -

Private Sub Download(ByVal downloadUrl As String)
Dim responseStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim reader As StreamReader = Nothing
Try
Dim downloadRequest As FtpWebRequest = _
WebRequest.Create(downloadUrl)

downloadRequest.Proxy = Nothing
downloadRequest.UsePassive = True
downloadRequest.UseBinary = True

downloadRequest.Credentials = New _
System.Net.NetworkCredential("xx", "xx")

Dim downloadResponse As FtpWebResponse = _
downloadRequest.GetResponse()

responseStream = downloadResponse.GetResponseStream()

Dim fileName As String = _

Path.GetFileName(downloadRequest.RequestUri.AbsolutePath)

If fileName.Length = 0 Then
reader = New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())
Else
fileStream = File.Create(fileName)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = responseStream.Read(buffer, 0,
buffer.Length)
If bytesRead = 0 Then
Exit While
End If
fileStream.Write(buffer, 0, bytesRead)
End While
End If
Console.WriteLine(downloadResponse.StatusCode & " " &
downloadResponse.StatusDescription)
Console.WriteLine("Download complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
ElseIf responseStream IsNot Nothing Then
responseStream.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
End Try
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top