0

I'm using SharpSSH to write files to a unix machine. The files are supposed to be read and then deleted up by another application which resides on the unix machine.
The problem is that the unix application does not have rights to delete the file. I can see the file's permissions are rw-r-----
Here is my code:

public override void WriteFileg(string directoryName, string fileName, string responseText, host, username, password, port) {
    // Write the file locally
    TextWriter writer = new StreamWriter("TempForSftp.txt");
    writer.WriteLine(responseText);
    writer.Close();

    // Transfer the local file
    Sftp sftp = new Sftp(host, username, password);
    sftp.Connect(int.Parse(port));
    sftp.Put("TempForSftp.txt", directoryName + "/" + fileName);
    sftp.Close();
}

How do I set different permissions?

4

1 に答える 1

2

SharpSshライブラリは、ファイルのアクセス許可を設定するメソッドを実装していないSFTPの非常に基本的な機能を実装しているようです。SSHシェル(SSHには1つのコマンドを実行するサブシステムチャネルがあるため、chmodを呼び出すことができます)を介してアクセス許可を設定することができます。それ以外の場合は、他のC#ライブラリを検索する必要があります。幸いなことに、それらはたくさんあります。

于 2012-11-09T14:40:59.657 に答える