我尝试将'.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 einenFehlerzurü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阶段)bei System.Net.FtpWebRequest.GetRequestStream()bei DVisualStudio中的Calendar.Calendar.Upload(String MitarbeiterNr) 2008CalendarCalendarCalendar.vbZeile 240。
很抱歉这是德语,但我想你们大多数人都可以阅读; - )
我从这里抓住了代码
如果有人帮助我尽快解决问题会很高兴=)
LightMonk
答案 0 :(得分:1)
始终检查在主机名之后和路径之前放置双斜杠的FTP连接字符串,例如ftp.mickeymouse // htdocs中/文件名。
当我有一个斜线maqrk时,我收到了一条完全没有帮助的错误550消息。
解决了我的问题,虽然这可能与此无关。