C# FTP上传后更改文件权限

C# FTP上传后更改文件权限,c#,.net-core,windows-server-2012,C#,.net Core,Windows Server 2012,我正在将桌面文件夹中的文件上载到Windows Server 2012服务器。 上载正在正确进行,但我需要更改上载文件的读取和删除权限。 在这段代码中我怎么做 string ftpIPServidor = "XXXX"; string ftpUsuarioID = "XX"; string ftpSenha = "XXXXXXX"; FileInfo _arquivoInfo = new FileInfo(_nomeArquivo); string u

我正在将桌面文件夹中的文件上载到Windows Server 2012服务器。
上载正在正确进行,但我需要更改上载文件的读取和删除权限。
在这段代码中我怎么做

    string ftpIPServidor = "XXXX"; 
    string ftpUsuarioID = "XX";
    string ftpSenha = "XXXXXXX";

    FileInfo _arquivoInfo = new FileInfo(_nomeArquivo);
    string uri = "ftp://" + ftpIPServidor + "/" + _arquivoInfo.Name;
    FtpWebRequest requisicaoFTP;
    requisicaoFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpIPServidor + "/" + _arquivoInfo.Name));

    requisicaoFTP.Credentials = new NetworkCredential(ftpUsuarioID, ftpSenha);

    requisicaoFTP.KeepAlive = false;

    requisicaoFTP.Method = WebRequestMethods.Ftp.UploadFile;

    requisicaoFTP.UseBinary = true;

    requisicaoFTP.ContentLength = _arquivoInfo.Length;

    // Define o tamanho do buffer para 2kb
    int buffLength = 2048;
    byte[] buff = new byte[buffLength];
    int _tamanhoConteudo;

    FileStream fs = _arquivoInfo.OpenRead();
    var horaAgora = DateTime.Now;

    try
    {
        Stream strm = requisicaoFTP.GetRequestStream();

        _tamanhoConteudo = fs.Read(buff, 0, buffLength);

        while (_tamanhoConteudo != 0)
        {
            // Escreve o conteudo a partir do arquivo para o stream FTP 
            strm.Write(buff, 0, _tamanhoConteudo);
            _tamanhoConteudo = fs.Read(buff, 0, buffLength);
        }

        strm.Close();
        fs.Close();

        Console.WriteLine(horaAgora + " :> Upload of " + _arquivoInfo.Name);
        fi.Delete();
    }
    catch (Exception ex)
    {
        Console.WriteLine(horaAgora + " :> Err " + _arquivoInfo.Name);

    }

在包
System.IO.FileSystem.AccessControl
中有名为
GetAccessControl
SetAccessControl
的扩展方法

更多信息请点击这里