我在网上搜索了一些如何在现有的hashmap中添加一些条目。
考虑以下代码:
foo={'bar':'go','new':'entry}
我想添加一个新条目并具有以下内容:
<#assign foo=foo+{'new':'entry'}>
我该怎么做?
答案 0 :(得分:0)
使用连接:
<#list foo?keys as k>
${k}: ${foo[k]} <br>
</#list>
打印hashmap:
bar: go
new: entry
结果正是您想要的:
SessionOptions sessionOptions= new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxx.xxx.xxx.xxx",
UserName = "root",
Password = "MyPasword",
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};
private void WinScp(SessionOptions sessionOptions, string sourceFilePath, string destinationFilePath)
{
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
//// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(sourceFilePath, destinationFilePath, true, transferOptions);
//// Throw on any error
transferResult.Check();
}
}
d