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

后端 未结 4 2251
悲哀的现实
悲哀的现实 2021-02-19 10:07

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:46

    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

提交回复
热议问题