0

The small utility that I've created builds just fine. But when I go to save the file, I get a debugging exception:

System.UnauthorizedAccessException has been thrown, Access to the path "/folder/file is denied.

The location to which I'm trying to write the file would normally require authentication, but my utility is not asking for it when I click save. How can I resolve this?

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
infinit_e
  • 57
  • 1
  • 10
  • 1
    Can you show us the code causing the error? – gotopie Jul 25 '12 at 23:10
  • @siege I hope this is what you're looking for, I'm rather new around here. Basically the application is creating a plist file for use with the built in OSX DHCP server. Below is the actual write string. `File.WriteAllText( "/etc/bootpd.plist", content1 + ifConfig.StringValue + content2 + serverName.StringValue + content3 + netAddress.StringValue + content4 + netMask.StringValue + content5 + startingIP.StringValue + content6 + endingIP.StringValue + content7 );` – infinit_e Jul 25 '12 at 23:29

1 Answers1

0

In general, when you get an UnauthorizedAccessException, you don't have the required security clearance (permission) to execute the action. Have a look at the code in this answer to see how to to get that permission.

Community
  • 1
  • 1
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
  • Thank you @Virtlink. I was fairly certain that was the problem already, but I'll definitely check out that answer. I'm really just trying to figure out how to get permission and apply it to the write operation. – infinit_e Jul 25 '12 at 23:50