简体   繁体   English

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

[英]How to copy files to a network path

I wnated to copy file form my local drive to network path. 我试图将文件从本地驱动器复制到网络路径。 I know how this can be achieved by using ssh ftp library ie using sftp.put(@ local, remote) , but i don't know how do do by using "sudo". 我知道如何通过使用ssh ftp库来实现,即使用sftp.put(@ local,remote),但是我不知道如何通过使用“ sudo”来实现。 What to do in case i don't have write permission to network path. 万一我没有对网络路径的写许可该怎么办。

Although i can remove file from network path by using following code : 虽然我可以使用以下代码从网络路径中删除文件:

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);

You can use use Copy, Delete, and Move Files and Folders and File.Copy method. 您可以使用“ 复制”,“删除”和“移动文件和文件夹”以及“ File.Copy”方法。

Also check out this . 另外,请查阅这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM