gpt4 book ai didi

c# - 如何将文件复制到网络路径

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:44 26 4
gpt4 key购买 nike

我想将文件从我的本地驱动器复制到网络路径。我知道如何通过使用 ssh ftp 库实现这一点,即使用 sftp.put(@local, remote) ,但我不知道如何使用“sudo”。如果我没有网络路径的写入权限怎么办。

尽管我可以使用以下代码从网络路径中删除文件:

string username = ConfigurationManager.AppSettings.Get("username");
string pass = ConfigurationManager.AppSettings.Get("password");
string filename;
filename = "standalone-full.xml";
string directory1;
directory1 = "apps/instances/express_13000/configuration";


// connecting to machine

SshExec ssh = new SshExec("machine", "user");
ssh.Password = "password";
ssh.Connect();
Console.WriteLine("Connection Established");

// removing files from server

string command_express = "echo" + "'" + pass + "'" + "| sudo -S -u wtsnqa " + "/" + directory1 + "/" + filename + "-exec rm";
string output1 = ssh.RunCommand(command_express);

最佳答案

您可以使用 Copy, Delete, and Move Files and FoldersFile.Copy方法。

另请查看 this .

关于c# - 如何将文件复制到网络路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18287575/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com