Reputation: 23
Manually, we can do that by opening a WinSCP and login to raspberry pi, give the permission to copy files, download that file from raspberry pi, copy it into the windows folder. But I want to make automatically in C#. Here I am trying to implement that manual process.
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();
}
but i don't know how to use WinSCP copy it, could anyone give me some ideas? thanks a lot.
Upvotes: 1
Views: 318
Reputation: 23
Just find a solution for myself, by using SCP (Secure Copy)
scp [email protected]:myfile.txt .
Upvotes: 1