我已经使用 C# 中的 FtpWebRequest 类实现了上传、下载、删除等功能.这是相当直接的.
I have implemented the ability to upload, download, delete, etc. using the FtpWebRequest class in C#. That is fairly straight forward.
我现在需要做的是支持发送任意FTP命令如
What I need to do now is support sending arbitrary FTP commands such as
quote SITE LRECL=132 RECFM=FB
or
quote SYST
这是直接来自我们的 app.config 的示例配置:
Here's an example configuration straight from our app.config:
<!-- The following commands will be executed before any uploads occur -->
<extraCommands>
<command>quote SITE LRECL=132 RECFM=FB</command>
</extraCommands>
我仍在研究如何使用 FtpWebRequest 来做到这一点.接下来我可能会尝试 WebClient 类.任何人都可以更快地指出我正确的方向吗?谢谢!
I'm still researching how to do this using FtpWebRequest. I'll probably try WebClient class next. Anyone can point me in the right direction quicker? Thanks!
更新:我得出了同样的结论,从 .NET Framework 3.5 FtpWebRequest 开始,除了 WebRequestMethods.Ftp.*.我将尝试其他一些帖子推荐的第三方应用程序.谢谢您的帮助!
UPDATE:
I've come to that same conclusion, as of .NET Framework 3.5 FtpWebRequest doesn't support anything except what's in WebRequestMethods.Ftp.*. I'll try a third party app recommended by some of the other posts. Thanks for the help!
我不认为用 FtpWebRequest... 指定 FTP 命令的唯一方法是通过 Method 属性,文档说明:
I don't think it can be done with FtpWebRequest... The only way to specify a FTP command is through the Method property, and the documentation states :
请注意,WebRequestMethods.Ftp 类中定义的字符串是 Method 属性唯一受支持的选项.将 Method 属性设置为任何其他值将导致 ArgumentException 异常.
Note that the strings defined in the
WebRequestMethods.Ftpclass are the only supported options for theMethodproperty. Setting theMethodproperty to any other value will result in anArgumentExceptionexception.
SITE 和 SYST 不在预定义选项中,所以我猜你被卡住了...
SITE and SYST are not among the predefined options, so I guess you're stuck...
不要浪费时间尝试 WebClient 类,它给你的灵活性比 FtpWebRequest 还要低.
Don't waste time to try the WebClient class, it will give you even less flexibility than FtpWebRequest.
但是,有很多第三方 FTP 实现,开源的或商业的,我很确定其中一些可以处理自定义命令...
However, there are plenty of third-party FTP implementation, open source or commercial, and I'm pretty sure some of them can handle custom commands...
这篇关于如何在 C# 中发送任意 FTP 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ASP.NET Core 使用 Azure Active Directory 进行身份验证并ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 进行身
ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用)
如何获取守护进程或服务器到 C# ASP.NET Web API 的How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何获取守护进程或服务器到 C# ASP.N
异步调用时 Azure KeyVault Active Directory AcquireTokenAAzure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(异步调用时 Azure KeyVault Active Directory AcquireTokenAsync 超
使用电子邮件地址和应用程序密码从 oauth2/tokenGetting access token using email address and app password from oauth2/token(使用电子邮件地址和应用程序密码从 oauth2/token 获取访问令
新的 Azure AD 应用程序在通过管理门户更新之前无New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 应用程序在通过管理门户更新之前无法运行