这是一个解决方案,如果您想控制哪些文件将通过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
}
TransferOptions.AddRawSettings
。除其他外,它不需要打开新的会话:TransferOptions.AddRawSettings
当然,您需要启用var options = new TransferOptions();
options.AddRawSettings("Masks", "*.*html; *.htm; *.txt; *.php; *.php3; ...");
:
然后您将options.TransferMode = TransferMode.Automatic;
实例与options
,Session.GetFiles
等方法一起使用