Hi,
I have what I believe is an odd problem. I am using the code given below to write to a pre-existing file. The write appears to happen okay. Copying the path into Notepad also allows the file to be viewed and edited okay. Nevertheless, the function gives an AccessDenied exception. Bit puzzled by this one. Does anyone have any idea what might be happening?
using( StreamWriter streamWriter = File.AppendText( "D:\...\Log.txt" ) )
{
streamWriter.Write( WebUtility.FixSingleNewline( "Some text." ) );
}
An update on the problem...
This code is actually being used in an ASP.NET website on my local machine. It seems I can make writes to the file in the Global Application_Start event, but when I try to call the code from a page, I get Access Denied. Do these two locations operate with different permission levels?
Kind wishes ~ Patrick
PS - I suspect I need to move this to the ASP.NET forum, but don't know how. Sorry.