1

我尝试将'.ics'文件上传到活动的 FTP 服务器

命名空间:

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

代码:

'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

使用的用户具有写入等所需的权限。URI 看起来像

ftp://Serveradress/Calendar/filename.ics

这是我得到的错误消息requestStrem = reqObj.GetRequestStream()

Der Remoteserver hat einen Fehler zurückgegeben (550) Datei nicht verfügbar (zB nicht gefunden oder kein Zugriff).System 来自 System.Net.FtpWebRequest.SyncRequestCallback(Object obj) 来自 System.Net.FtpWebRequest.RequestCallback(Object obj) 来自 System.Net .CommandStream.InvokeRequestCallback(Object obj) bei System.Net.CommandStream.Abort(Exception e) bei System.Net.FtpWebRequest.FinishRequestStage(RequestStage 阶段) bei System.Net.FtpWebRequest.GetRequestStream() bei Calendar.Calendar.Upload(String MitarbeiterNr) 在 DVisualStudio 2008CalendarCalendarCalendar.vbZeile 240 中。

抱歉,它是德文的,但我想你们中的大多数人都能读到;-)

我从这里抢了代码

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

如果有人帮助我尽快解决问题会很高兴=)

光僧

4

1 回答 1

1

始终检查在主机名之后和路径之前放置双斜杠的 FTP 连接字符串,例如 ftp.mickeymouse//htdocs/filename。

当我只有一个斜线 maqrk 时,我收到了一条完全没有帮助的错误 550 消息。

解决了我的问题,尽管在这里可能不相关。

于 2012-12-22T14:56:37.073 回答