【发布时间】:2019-05-15 09:47:07
【问题描述】:
手动,我们可以通过打开 WinSCP 并登录到树莓派,授予复制文件的权限,从树莓派下载该文件,将其复制到 windows 文件夹中。 但我想在 C# 中自动制作。在这里,我正在尝试实现该手动过程。
public void OpenMyRaspberrypi(string Session_Name)
{
#region Create SSH_Get_Date
if (!File.Exists(CommandFilePath))
{
using (StreamWriter sw = File.CreateText(CommandFilePath))
{
sw.WriteLine("cd /usr/local/myTarget.json");
sw.WriteLine("chmod 777 myTarget.json");
}
}
#endregion
strCmdText = "/C plink -load " + Session_Name + " -l username -pw password -m " + CommandFilePath;
System.Diagnostics.Process process = new System.Diagnostics.Process();
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = strCmdText;
process.Start();
}
但我不知道如何使用 WinSCP 复制它,谁能给我一些想法?非常感谢。
【问题讨论】:
-
有一个适用于 .NET 的 WinSCP 库,在这里可能会有所帮助:winscp.net/eng/docs/library
标签: c# copy raspberry-pi3 winscp