FTP 服务器的 URI 问题

发布于 2024-09-06 09:04:06 字数 385 浏览 3 评论 0原文

由于找不到正确的 URI,我无法通过 C# 访问 FTP 服务器。 可以使用 ftp.xxx.com 找到 ftp 服务器 - 因此 ftp ftp.xxx.com 从命令行工作,ftp ftp ://ftp.xxx.com 通过命令行产生未知主机。 使用时也会发生同样的情况

FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(new Uri(Settings.Default.FtpServer, UriKind.Absolute));

在我的 C# 程序中 我做错了什么/我需要如何确定 URI?

I am having trouble to access a FTP server via C# because of not finding the right URI.
The ftp server can be found using ftp.xxx.com - thus ftp ftp.xxx.com works from the command line, ftp ftp://ftp.xxx.com yields unknown host via the command line. The same happens then when using

FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(new Uri(Settings.Default.FtpServer, UriKind.Absolute));

inside my C# program
What am I doing wrong/how do I need to determine the URI?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一曲琵琶半遮面シ 2024-09-13 09:04:06

您设置了哪个 WebRequestMethod?如果设置为下载文件,则可能会失败,因为您的 URI 不是指向文件而是指向服务器的根目录。
我不确定这是否是要点,无法亲自测试,但在我看来是合乎逻辑的。

编辑:
默认方法是 DownloadFile(使用反射器查找)

Which WebRequestMethod do you set? If its set to download a file, it might fail because your URI is not pointing to a file but to the root directory of the server.
Im not sure if its the point can't test it myself but looks logically to me.

edit:
Default Method is DownloadFile (looked up with reflector)

︶ ̄淡然 2024-09-13 09:04:06

FinalUri = ftp://11.11.11.11/ + Uri.EscapeDataString(文件夹) + / + Uri.EscapeDataString(文件夹) ... / + Uri.EscapeDataString(文件名)

finalUri = ftp://11.11.11.11/ + Uri.EscapeDataString(folder) + / + Uri.EscapeDataString(folder) ... / + Uri.EscapeDataString(filename)

欲拥i 2024-09-13 09:04:06

尝试一下

FtpWebRequest reqFTP = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + xx.xx.xx.xx + "/" + FileName));

Try It

FtpWebRequest reqFTP = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + xx.xx.xx.xx + "/" + FileName));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文