我正在寻找问题的解决方案,我无法下载名称中包含空格的文件。
编辑:我发现ftp服务器在linux上运行,我的连接代码需要设置为utf-8?这是真的吗?
我试图传递不同版本的文件名:
带空格的名称
名称%20with%20Space
姓名/有/空格
名称/带/空间
名称 “/” 与 “/” 空间
但没有任何效果。这是我的代码
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
有人知道有效的解决方案吗?
答案 0 :(得分:-1)
你是否试过覆盖整条路径&#34;&#34;标记
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"
的字符串。