首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试写入文件时访问被拒绝

问尝试写入文件时访问被拒绝
EN

Stack Overflow用户
提问于 2020-02-18 23:28:41
回答 1查看 17关注 0票数 0

您好,我正在尝试写一个文件,但当我运行程序时,它显示访问被拒绝,我已经尝试检查安全权限,并以管理员身份打开VS,但不起作用这里是构建文件的函数

代码语言:javascript
复制
public void fazfich() {
    string createText = "\"" + this.Companhia + "\",\"" + this.NrFuncionario + "\",\"" + this.Nome1 + "\",\"" + this.Nome2 + "\",\"" + this.DtNascimento + "\",\"" + this.Sexo +
        "\",\"" + this.PIN + "\",\"" + this.EMAIL + "\",\"" + this.TpColaborador + "\",\"" + this.CodLingua + "\",\"" + this.CodLingualSO + "\",\"" + this.CodCentroCst +
        "\",\"" + this.CodEscala + "\",\"" + this.CodSector + "\",\"" + this.CodCentroTrb + "\",\"" + this.CodDirecao + "\",\"" + this.CodCategoria + "\",\"" + this.CodCompnhiaExt +
        "\",\"" + this.DsCompanhiaExt + "\",\"" + this.Telefone + "\",\"" + this.InfAutomaticas + "\",\"" + this.HorasExtra + "\",\"" + this.TpControlo +
        "\",\"" + this.CodGrpControlo + "\",\"" + this.NrFuncionarioAlt + "\",\"" + this.TpHorario + "\",\"" + this.TolAtrasoDia + "\",\"" + this.TolAtrasoPrd +
        "\",\"" + this.TolSaidaDia + "\",\"" + this.TolSaidaPrd + "\",\"" + this.SaldoDia + "\",\"" + this.SaldoPrd + "\",\"" + this.TemSaldo + "\",\"" + this.Sistema +
        "\",\"" + this.Saldo + "\",\"" + this.TemCredito + "\",\"" + this.PrecoRefeicao + "\",\"" + this.Subsidio + "\",\"" + this.NrRefeircoes + "\",\"" + this.TpPaga +
        "\",\"" + this.CodPaga + "\",\"" + this.Info + "\",\"" + this.Obs + "\",\"" + this.DtAdmissao + "\",\"" + this.DtDemissao + "\",\"" + this.SisLogico + "\",\"" +
        this.Cartao + "\",\"" + this.DtValidadeIni + "\",\"" + this.DtValidadeFim + "\",\"" + this.Versao + "\",\"" + this.NomeCartao + "\",\"" + this.CodGrpPermissao +
        "\",\"" + this.CodPerfil + "\",\"" + this.PINCARTAO + "\",\"" + this.Status + "\",\"" + this.Info1 + "\",\"" + this.Info2 + "\",\"" + this.Info3 + "\",\"" +
        this.Info4 + "\",\"" + this.Info5 + "\",\"" + this.Info6 + "\",\"" + this.Info7 + "\",\"" + this.Info8 + "\",\"" + this.Info9 + "\",\"" + this.Info10 + "\",\"" +
        this.Msg1 + "\",\"" + this.Msg2 + "\",\"" + this.Provisorio + "\",\"" + this.IDAplicaçã o + "\",\"" + this.AgrpSalarios + "\",\"" + this.Visitante + "\",\"" +
        this.Empresa + "\"\r\n";
    File.WriteAllText(@"C:\Users\ec2ac9097\Documents\estagio\WebApplicationAPI", createText);
}

该程序是一个Web API

EN

回答 1

Stack Overflow用户

发布于 2020-02-19 00:35:20

API将在某个特定用户下运行,您可以在IIS设置下查看该用户。该特定用户没有在用户文件夹中创建内容的权限,就像您尝试写入文件的位置一样。

您可以通过尝试在IIS具有完全访问权限的其他位置(如inetpub或您的临时文件夹)进行验证。

绝对不要用IIS Express测试它,从一开始就在IIS中设置它。最后,如果您想要在磁盘上创建文件,则必须设置具有特定权限的特定用户。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60284328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档