Access to the path 'C:\Users\xxx\Desktop' is denied

后端 未结 5 441
北恋
北恋 2021-01-07 17:10

I have thoroughly searched the entire access denied questions and did\'t find any question related to access to windows form on my own system all the questions are related t

5条回答
  •  孤城傲影
    2021-01-07 17:35

    "C:\\Users\\username\\Desktop" is a directory for me; not a file.

    Since you're attempting to open the file, this:

    fsrw = new FileStream("C:\\Users\\Sainath\\Desktop", FileMode.Open, FileAccess.ReadWrite);
    

    ... should be

    var fullpath = Path.Combine("C:\\Users\\Sainath\\Desktop", fname);
    fsrw = new FileStream(fullpath, FileMode.Open, FileAccess.ReadWrite);
    

提交回复
热议问题