|
Have a question about creating a folder to ask a master
C# code:
DirectoryInfo di=Directory.CreateDirectory(@"C:\Inetpub\wwwroot\Public\Html");
Error:
Server error in the "/NewsType" application.
-------------------------------------------------- ------------------------------
Access to the path "C:\Inetpub\wwwroot\Public\Html" is denied.
Explanation: During the execution of the current web request, an unhandled exception occurred. Please check the stack trace for details about the error and the source of the error in the code.
Exception details: System.UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\Public\Html" is denied.
ASP.NET is not authorized to access the requested resource. Please consider granting ASP.NET request ID access to this resource. ASP.NET has a base process identifier that is used when the application is not emulated (usually {MACHINE}\ASPNET on IIS 5, and network service on IIS 6). If the application is impersonating via <identity impersonate="true"/>, the identity will be an anonymous user (usually IUSR_MACHINENAME) or an authenticated requesting user.
To grant ASP.NET write access to a file, right-click the file in Explorer, select "Properties", and then select the "Security" tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account and check the box corresponding to the required access permissions.
Source error:
Line 21: {
Line 22: // Place user code here to initialize the page
Line 23: DirectoryInfo di=Directory.CreateDirectory(@"C:\Inetpub\wwwroot\Public\Html");
Line 24: //di.Create();
Line 25: Response.Write(di.Parent.Name);
Source file: c:\inetpub\wwwroot\newstype\webform2.aspx.cs Line: 23
Stack trace:
[UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\Public\Html" is denied. ]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.Directory.InternalCreateDirectory(String fullPath, String path) +632
System.IO.Directory.CreateDirectory(String path) +195
NewsType.WebForm2.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\newstype\webform2.aspx.cs:23
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731 |
|