2014-08-27 76 views
0

我正在尋找一個解決方案的問題,我不能下載一個文件的名稱空間。從FTP獲取文件的空間在文件名VB 2010

編輯:我發現ftp服務器在linux上運行,我的連接代碼需要設置爲utf-8?這可能是真的嗎?

我試圖通過不同版本的文件名:

名稱與空間

名稱%20with%20Space

名稱/帶/空間

名稱/帶/空間

名稱「/」加「/」空格

但是n沒有工作。這裏是我的代碼

Dim ftpRequest As FtpWebRequest = System.Net.FtpWebRequest.Create(myFTPPath & My ftp name with space) 

     ftpRequest.Credentials = New System.Net.NetworkCredential(User, Password) 

Dim ftpResponse As System.Net.FtpWebResponse = Nothing 
      Dim iTries As Integer = 0 
      Do While (IsNothing(ftpResponse) And iTries < 10) 
       iTries += 1 
       ftpResponse = getResponse(ftpRequest) 
      loop 
.......... 
........... 
........... 


Private Shared Function getResponse(ByRef request As FtpWebRequest) As FtpWebResponse 
    Dim res As Boolean = False 
    Dim response As System.Net.FtpWebResponse = Nothing 
    Try 
     response = request.GetResponse 
    Catch ex As WebException 

     If ex.Status = WebExceptionStatus.ConnectFailure Then 
      response = Nothing 
     End If 
    End Try 
    Return response 
End Function 

任何人都知道一個工作解決方案?

回答

-1

您是否試過掩蓋整個路徑「」標記?

Dim ftpRequest As FtpWebRequest = System.Net.FtpWebRequest.Create("""ftp://example.com/directory with withespace/file with whitespace.txt""") 

當你想這會產生

"ftp://example.com/directory with withespace/file with whitespace.txt" 

字符串。