【问题标题】:Writing file denied写入文件被拒绝
【发布时间】:2021-07-28 23:21:42
【问题描述】:

我在写入文件时遇到错误,这让我发疯。
我有一个在 RH Linux 上运行的 C# netcore 5 应用程序。
我使用以下方式安装了一个共享文件夹(Windows):sudo mount -t cifs -o username=MyDomainUsername,password=MyDomainUsernamePassword,domain=MyDomain,dir_mode=0777,file_mode=0777 //ipv4_from_destination/Reports /fileshare/Reports
然后我运行应用程序,只使用./WebApi --urls=http://+:8060
读/写测试执行以下步骤:

  1. 创建一个文本文件。
  2. 编写文本文件。
  3. 删除文本文件。
  4. 创建目录
  5. 在该目录中创建一个文本文件
  6. 写入文本文件
  7. 删除文本文件
  8. 删除目录。

现在的问题:

  1. 文本文件已创建
  2. 写入操作失败。

日志的一部分在哪里:

Creating file: /fileshare/Reports/test.616db7d1-07fb-4599-a0cf-749e6a8b34ec.tmp...Ok
Writing file: /fileshare/Reports/test.616db7d1-07fb-4599-a0cf-749e6a8b34ec.tmp...[16:22:20 ERR] ID:87988856-a765-4474-9ed9-2f04aef35771 PATH:/api/about ERROR:System.UnauthorizedAccessException:Access to the path '/fileshare/Reports/test.616db7d1-07fb-4599-a0cf-749e6a8b34ec.tmp' is denied. TRACE:   at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
   at System.IO.FileStream.FlushWriteBuffer()
   at System.IO.FileStream.FlushInternalBuffer()
   at System.IO.FileStream.Flush(Boolean flushToDisk)
   at System.IO.FileStream.Flush()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Flush()
   at WebApi.Controllers.ApplicationController.TestFileSystem(String folder) in xxxxxxx\WebApi\Controllers\ApplicationController.cs:line 116

到目前为止我发现了什么:
我可以创建和删除文件和目录。
我无法写入文件。

有人可以给我一个提示吗?

【问题讨论】:

    标签: linux redhat permission-denied cifs windows-share


    【解决方案1】:

    使用 cifs 选项解决 nobrl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      • 2012-07-12
      • 2023-04-01
      • 2018-08-12
      相关资源
      最近更新 更多