C# 如何将文件从 raspberry pi 3B+ 复制到 windows 本地文件夹

C# how to copy file from raspberry pi 3B+ to windows local folder

手动,我们可以通过打开 WinSCP 并登录到 raspberry pi,授予复制文件的权限,从 raspberry pi 下载该文件,将其复制到 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复制它,谁能给我一些想法?非常感谢。

通过使用 SCP(安全复制)为自己找到一个解决方案

scp pi@192.168.0.1:myfile.txt .