justdriveon
asked on
Can't create or write to a file w/ASP.NET: UnauthorizedAccessException
I have a C# ASP.NET 2.0 application that needs to write some simple logging records to an XML file in the bin directory under the www root. If I attempt to create or write to the file, I get an UnauthorizedAccessExceptio n. (Access to the path 'D:\webadmin\www\bin\test. xml' is denied). My server administrator says the ASP.NET user has write access to the bin directory, and I'm not sure what else the problem could be.
My testing code... this code is compiled code-behind in the bin directory (same directory I'm trying to write to) and the ASPX page is up one directory (under the root).
filepath = @"D:\webadmin\www\bin\test .xml"
if (!File.Exists(filepath)) {
File.Create(filepath); //Error is thrown here.
}
My testing code... this code is compiled code-behind in the bin directory (same directory I'm trying to write to) and the ASPX page is up one directory (under the root).
filepath = @"D:\webadmin\www\bin\test
if (!File.Exists(filepath)) {
File.Create(filepath); //Error is thrown here.
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am also giving Kate12 points because when googling this problem I could not find anything about these FileSecurity/FolderSecurit