|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
FTPWEBRequest always return error 5501. 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 In article <1173104033.831894.292***@q40g2000cwq.googlegroups.com>,
Edison.***@gmail.com says... Show quote > I'm facing a prblem with FTPWebRequest of .NET v2.0 I would use TcpTrace (http://www.pocketsoap.com/tcptrace/) and monitor > 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. the traffic from .NET's FTPWebRequest as well as WS-FTP and make sure they're sending the same FTP commands. 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 Steele wrote: Show quote > In article <1173104033.831894.292***@q40g2000cwq.googlegroups.com>, > Edison.***@gmail.com says... > > 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. > > -- > Patrick Steele > http://weblogs.asp.net/psteele In article <1173177449.622730.77***@30g2000cwc.googlegroups.com>,
Edison.***@gmail.com says... > I used ethereal and found that the error was due to FtpWebRequest Not sure. I'm not really impressed with the FTP classes in .NET 2.0:> transmitting an erroneous command- CWD c:\/c:/ > > Is there a way to correct this? http://tinyurl.com/2q7kxy What's the full URI you're using? On Mar 7, 7:26 am, Patrick Steele <patr***@mvps.org> wrote:
Show quote > In article <1173177449.622730.77***@30g2000cwc.googlegroups.com>, My url is ftp://aa.bb.cc.dd/c:/TextFile.txt.> Edison.***@gmail.com says... > > > 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? > > -- > Patrick Steelehttp://weblogs.asp.net/psteele 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 In article <1173243541.949411.297***@n33g2000cwc.googlegroups.com>,
Edison.***@gmail.com says... > 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. Patrick Steele wrote:
> In article <1173243541.949411.297***@n33g2000cwc.googlegroups.com>, I created a directory with name as "c:" in a Linux and my app was able> Edison.***@gmail.com says... > > 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. > > -- > Patrick Steele > http://weblogs.asp.net/psteele 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 In article <1173446930.045492.117***@64g2000cwx.googlegroups.com>,
Edison.***@gmail.com says... > I created a directory with name as "c:" in a Linux and my app was able Not that I know of. There's a bunch of free FTP source code out there > 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? that would probably eliminate this problem. |
|||||||||||||||||||||||