2012-05-30 113 views
1

我嘗試'.ics'文件上傳到活動的FTP服務器VB.NET FTP錯誤550

命名空間:

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()

明鏡REMOTESERVER帽子einen Fehlerzurückgegeben(550)Datei nicht verfügbar(z.B. nicht gefunden奧德KEIN Zugriff)。系統貝 System.Net.FtpWebRequest.SyncRequestCallback(對象OBJ)貝 System.Net.FtpWebRequest.RequestCallback(對象OBJ)貝 System.Net.CommandStream.InvokeRequestCallback(對象OBJ)貝 系統.Net.CommandStream.Abort在DVisualStudio 2008CalendarCalendarCalendar(例外五)貝 System.Net.FtpWebRequest.FinishRequestStage(RequestStage階段)貝 System.Net.FtpWebRequest.GetRequestStream()貝 Calendar.Calendar.Upload(字符串MitarbeiterNr)。 vbZeile 240.

對不起,這是德文,但我認爲你們大多數人都可以閱讀; - )

我搶走了代碼從這裏

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

會很高興,如果有人可以幫助我解決這個問題很快=)

LightMonk

回答

1

始終檢查在FTP連接字符串中,在主機名和路徑之前放置雙斜槓,例如ftp.mickeymouse // htdocs目錄/文件名。

當我有onlty一斜槓maqrk我得到了一個完全無益的錯誤550消息。

解決了我的問題,雖然這可能與此無關。