WinSCP .NET程序集自定义列表,定义了TransferMode == Automatic时的ASCII传输

问题描述 投票:0回答:1

这是一个解决方案,如果您想控制哪些文件将通过ASCII或BINARY自动传输而无需在C#中编写WinSCP的控制语句,则必须在该会话上创建一个新会话

AddRawConfiguration(@"Interface\CopyParam\Masks", ...)

例如:

using (var session = new Session())
{
    var asciiFileMasks = "*.xsl; *.xslt; *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml";
    session.AddRawConfiguration(@"Interface\CopyParam\Masks", asciiFileMasks );//for automatic transfers, this list determines ascii or binary mode

   ///... do your thing
}
c# .net ftp winscp winscp-net
1个回答
0
投票
更好的解决方案是使用TransferOptions.AddRawSettings。除其他外,它不需要打开新的会话:

TransferOptions.AddRawSettings

当然,您需要启用var options = new TransferOptions();
options.AddRawSettings("Masks", "*.*html; *.htm; *.txt; *.php; *.php3; ...");

automatic transfer mode

然后您将options.TransferMode = TransferMode.Automatic;
实例与optionsSession.GetFiles等方法一起使用
© www.soinside.com 2019 - 2024. All rights reserved.