连接到FTP服务器

编程入门 行业动态 更新时间:2024-10-28 18:34:36
本文介绍了连接到FTP服务器 - 远程服务器返回错误:(550)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到错误远程服务器返回错误:(550)文件不可用(例如,文件未找到,无法访问)。当我调用函数sendFile2FTP

时>

函数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 =新的Net.NetworkCredential(用户,密码) ftpRequest.Method = Net.WebRequestMethods.Ftp。 UploadFile 尝试 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() 返回True捕捉前例如返回ex.Message 结束尝试 结束功能

这是我发送给函数的参数(全部有效) lockquote fileNameLocal C:\Users\user\\ \\ Documents \ Visual Studio 2013 \Projects\AgenteExportDebitosCC\AgenteExportDebitosCC\bin\Debug\file02-05-2014.xml

fileNameServer - > ftp://ftp.server/intranet/file02-05-2014.xml 用户 - >用户

密码 - >密码

我做错了什么?

编辑:

我不确定if这是一个权限问题,但我可以使用相同的凭证创建filezilla文件...

解决方案

问题出在关于ftp地址。而不是

ftp://ftp.server/intranet/file02-05-2014.xml

我必须在地址中使用用户名

ftp://username@ftp.server/server/intranet/file02-05-2014.xml

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:\Users\user\Documents\Visual Studio 2013\Projects\AgenteExportDebitosCC\AgenteExportDebitosCC\bin\Debug\file02-05-2014.xml

fileNameServer -> ftp://ftp.server/intranet/file02-05-2014.xml user -> user

password ->password

What am I doing wrong?

Edit:

I'm not sure if this is a permission issue, but I am able to create files with filezilla using the same credentials...

解决方案

The issue was regarding the ftp address. Instead of

ftp://ftp.server/intranet/file02-05-2014.xml

I had to use the username in the address

ftp://username@ftp.server/server/intranet/file02-05-2014.xml

更多推荐

连接到FTP服务器

本文发布于:2023-10-23 01:30:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   服务器   FTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!