Ok, so I think I'm doing something very simple here. I wrote an ASP.NET webpage and it just tries to write to a local directory.
I am using the following code:
System.IO.File.WriteAllLines("log.txt", messages);
I throw the following exception.
Access to the path 'c:\windows\system32\inetsrv\log.txt' is denied.
The ASP.NET application is located in the following directory.
c:\inetpub\wwwroot\sites\mysite\
So, I am confused by why he is trying to write the directory c: \ windows \ system32 \ inetsrv \ when I do not supply this directory myself.
I tried changing the code to the next, but it gives me the same error message with the new directory.
System.IO.File.WriteAllLines("c:\\inetpub\\wwwroot\\sites\mysite\log.txt", messages);
Change 1
It was difficult to accept the answer to this, because everyone really helped me per ton. I accepted tom_yes_tom's answer because he was the first to post his answer, which was the first half of my problem. The other half of my problem was related to the hbrock solution that Fabio pointed out.
meanbunny
source share