我尝试将'.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 中。
抱歉,它是德文的,但我想你们中的大多数人都能读到;-)
我从这里抢了代码
如果有人帮助我尽快解决问题会很高兴=)
光僧