VB.net 4.0 - 连接到FTP服务器 - 远程服务器返回错误:(550) [英] VB.net 4.0 - connecting to FTP server - The remote server returned an error: (550)
问题描述
我收到了错误的远程服务器返回错误:(550)文件不可用(例如,未找到文件,没有访问权限)的当我把我的函数sendFile2FTP
I'm getting the error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)." when I call my function sendFile2FTP
Function sendFile2FTP(fileNameLocal As String, fileNameServer As String, user As String, password As String) As String
Dim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create(fileNameServer)
ftpRequest.Credentials = New Net.NetworkCredential(user, password)
ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
Try
Dim ficheiro() As Byte = System.IO.File.ReadAllBytes(fileNameLocal)
Dim ftpStream As System.IO.Stream = ftpRequest.GetRequestStream()
ftpStream.Write(ficheiro, 0, ficheiro.Length)
ftpStream.Close()
ftpStream.Dispose()
Return "True"
Catch ex As Exception
Return ex.Message
End Try
End Function
这是我送的功能(这些都是有效的)
And this are the parameters that i'm sending to the function (which are all valid)
fileNameLocal - > C:\用户\用户\文档\ Visual Studio的2013 \项目\ AgenteExportDebitosCC \ AgenteExportDebitosCC \斌\调试\ file02-05-2014.xml
fileNameLocal -> C:\Users\user\Documents\Visual Studio 2013\Projects\AgenteExportDebitosCC\AgenteExportDebitosCC\bin\Debug\file02-05-2014.xml
fileNameServer - > ftp://ftp.server.com/intranet/file02 -05-2014.xml
用户 - >用户
fileNameServer -> ftp://ftp.server.com/intranet/file02-05-2014.xml
user -> user
密码 - >密码
我是什么做错了吗?
编辑:
我不知道这是否是权限问题,但我能够创建使用相同的凭据与FileZilla的文件...
I'm not sure if this is a permission issue, but I am able to create files with filezilla using the same credentials...
推荐答案
这个问题是关于FTP地址。而不是
The issue was regarding the ftp address. Instead of
ftp://ftp.server.com/intranet/file02-05- 2014.xml
我不得不使用的用户名在地址
I had to use the username in the address
FTP://username@ftp.server。 COM / server.com /内联网/ file02-05-2014.xml
这篇关于VB.net 4.0 - 连接到FTP服务器 - 远程服务器返回错误:(550)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!