Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用SSH.NET SftpClient设置扩展文件属性_C#_.net_Sftp_Openssh_Ssh.net - Fatal编程技术网

C# 使用SSH.NET SftpClient设置扩展文件属性

C# 使用SSH.NET SftpClient设置扩展文件属性,c#,.net,sftp,openssh,ssh.net,C#,.net,Sftp,Openssh,Ssh.net,在我使用Renci SSH.NET SFTP库将文件从Windows上传到远程计算机(ubuntu16.04 LTS)后,我尝试使用extended file属性来存储一些信息。但是这些属性没有得到保留 这就是我试图设置扩展属性的方式 SftpFileAttributes fileAttrs = sftpClient.GetAttributes(remoteFilePath); IDictionary<string, string> additionalAttrs = new Dic

在我使用Renci SSH.NET SFTP库将文件从Windows上传到远程计算机(ubuntu16.04 LTS)后,我尝试使用extended file属性来存储一些信息。但是这些属性没有得到保留

这就是我试图设置扩展属性的方式

SftpFileAttributes fileAttrs = sftpClient.GetAttributes(remoteFilePath);
IDictionary<string, string> additionalAttrs = new Dictionary<string, string>();
additionalAttrs.Add(new KeyValuePair<string, string>("user.from", "abc"));
additionalAttrs.Add(new KeyValuePair<string, string>("user.to", "xyz"));
fileAttrs =
    new SftpFileAttributes(
        fileAttrs.LastAccessTime, fileAttrs.LastWriteTime, fileAttrs.Size,
        fileAttrs.UserId, fileAttrs.GroupId, 222, additionalAttrs);
sftpClient.SetAttributes(remoteFilePath, fileAttrs);
SftpFileAttributes fileAttrs=sftpClient.GetAttributes(remoteFilePath);
IDictionary additionalAttrs=新字典();
additionalAttrs.Add(新的KeyValuePair(“user.from”、“abc”);
additionalAttrs.Add(新的KeyValuePair(“user.to”,“xyz”));
文件属性=
新的SftpFileAttributes(
fileAttrs.LastAccessTime、fileAttrs.LastWriteTime、fileAttrs.Size、,
fileAttrs.UserId、fileAttrs.GroupId、222、additionalAttrs);
SetAttributes(remoteFilePath、fileAttrs);

那么,你能帮我解决这个问题吗请注意:出于安全原因,远程计算机配置为仅允许SFTP连接。

您不能添加随机扩展属性,如
user.from
。您只能添加服务器明确支持的属性

您没有指定正在使用的SFTP服务器。但是,当您连接到Ubuntu服务器时,可以假设它是最广泛使用的*nix SFTP服务器OpenSSH。OpenSSH不支持任何扩展属性。它默默地忽略了所有这些


另见这些讨论:

  • (OpenSSH)
  • (ProFTPD)
以及SFTP规范的相关章节: