Could not find a part of the path 'C:\Program Files (x86)\IIS Express\~\TextFiles\ActiveUsers.txt'

后端 未结 4 1941
滥情空心
滥情空心 2021-02-19 10:13

I tried many ways to access a text file in my Visual Studio 2012 Solution from a folder named TextFiles

using (System.IO.StreamWriter file = new Sys         


        
4条回答
  •  野性不改
    2021-02-19 10:50

    This is an old question but I just ran into this problem myself and wanted to add what I've just discovered, in case it's helpful to anyone else.

    If you have UAC turned off but are not running with elevated permissions, and try to write to restricted files (e.g. the "Program Files" folder) you'll get the "could not find a part of the path" error, instead of the (correct) access denied error.

    To eliminate the problem, run with elevated permissions as in this solution: https://stackoverflow.com/a/1885543/3838199

提交回复
热议问题