UnauthorizedAccessException when saving file, but can create a directory

前端 未结 1 783
[愿得一人]
[愿得一人] 2021-01-15 09:53

I\'m trying to save a file to the disk but I get UnauthorizedAccessException. The error says I have to get the right permissions on the folder, and I\'ve tried every possibl

相关标签:
1条回答
  • 2021-01-15 10:44

    Turns out what I was trying to do was saving the folder and not the file, I forgot to combine the fileName with the path.

    Changed the Save part to the following:

    file.SaveAs(Path.Combine(path, fileName));
    

    Which solved the whole thing for me.

    0 讨论(0)
提交回复
热议问题