VB.NET FTP Error 550

2019-08-05 14:13发布

I try to upload '.ics' Files to an active FTP Server

Namespaces:

Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Collections
Imports Microsoft.VisualBasic
Imports System.Net
Imports System.Text

Code:

'Create a FTP Request Object and Specfiy a Complete Path
                Dim reqObj As FtpWebRequest = WebRequest.Create(Ziel + "Calendar/" + MitarbeiterNr + ".ics")
                reqObj.Method = WebRequestMethods.Ftp.UploadFile
                reqObj.UsePassive = False
                reqObj.Credentials = New NetworkCredential(User, Password)
                reqObj.Proxy = Nothing
                reqObj.KeepAlive = False
                reqObj.UseBinary = False
                reqObj.Timeout = 5000


                Dim sourceStream As FileStream = File.OpenRead(AppPath + "Ablage\" + MitarbeiterNr + "\" + MitarbeiterNr + ".ics") ' store file in buffer
                Dim buffer(Convert.ToInt32(sourceStream.Length)) As Byte
                sourceStream.Read(buffer, 0, buffer.Length)
                sourceStream.Close()
                reqObj.ContentLength = buffer.Length
                'Dim objUTF8 As New UTF8Encoding()
                'lblMsg.Text &= objUTF8.GetString(buffer)


                'Upload File and set its object to nothing
                Dim requestStream As System.IO.Stream
                Try
                    requestStream = reqObj.GetRequestStream() 'times out here
                    requestStream.Write(buffer, 0, buffer.Length)
                    requestStream.Close()
                Catch ex As Exception
                    Debug.printMeldung(ex.Message & ex.Source & ex.StackTrace)
                End Try


                reqObj = Nothing

The used User has the needed rights for Writing etc. the URI looks like

ftp://Serveradress/Calendar/filename.ics

Here is the Error Message I get by requestStrem = reqObj.GetRequestStream():

Der Remoteserver hat einen Fehler zurückgegeben (550) Datei nicht verfügbar (z.B. nicht gefunden oder kein Zugriff).System bei System.Net.FtpWebRequest.SyncRequestCallback(Object obj) bei System.Net.FtpWebRequest.RequestCallback(Object obj) bei System.Net.CommandStream.InvokeRequestCallback(Object obj) bei System.Net.CommandStream.Abort(Exception e) bei System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) bei System.Net.FtpWebRequest.GetRequestStream() bei Calendar.Calendar.Upload(String MitarbeiterNr) in DVisualStudio 2008CalendarCalendarCalendar.vbZeile 240.

Sorry that it is in German but I think most of you can read that ;-)

I snatched the code from here

http://forums.asp.net/post/2590178.aspx

Would be happy if someone helps me to solve the Problem soon =)

LightMonk

1条回答
放荡不羁爱自由
2楼-- · 2019-08-05 14:26

Always check in FTP connection strings that you put a double slash after host name and before the path, e.g. ftp.mickeymouse//htdocs/filename.

When I had onlty one slash maqrk I got a totally unhelpful error 550 message.

Solved my problems, though it may not be relevant here.

查看更多
登录 后发表回答