Excel 파일을 업로드 할 때이 오류가 발생합니다. 누구든지 도와 줄 수 있습니까? 파일 뒤에업로드시 거부 된 파일 경로에 대한 액세스
Access to the path 'C:\Data\IronElements\Upload\AUMData\20101202 031815.xlsx' is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\Data\IronElements\Upload\AUMData\20101202 031815.xlsx' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
내 코드는 다음과 같은 구문을
DateTime date = DateTime.Now;
string FileName = Convert.ToString(date.ToString("yyyyMMdd hhmmss"));
Directory.CreateDirectory("C:\\Data\\IronElements\\Upload\\AUMData\\Schema");
doesFileExists("C:\\Data\\IronElements\\Upload\\AUMData\\Schema");
fileUpload.PostedFile.SaveAs("C:\\Data\\IronElements\\Upload\\AUMData\\" + FileName + ".xlsx");
System.Threading.Thread.Sleep(5000);
string connectionString = WebConfigurationManager.ConnectionStrings["SQLConnection"].ConnectionString;
SqlConnection SqlConnect = new SqlConnection(connectionString);
try
{
SqlConnect.Open();
SqlCommand cmdAssetUnderManagement = new SqlCommand("Exec_Insert_AUMAssetValue", SqlConnect);
cmdAssetUnderManagement.CommandType = CommandType.StoredProcedure;
cmdAssetUnderManagement.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
SqlConnect.Close();
}
lblAUMTA.Visible = true;
lblAUMTA.Text = "File Upload Completed";
}
private void doesFileExists(string p)
{
p = string.Concat(p, "\\AUMSchema.xlsx");
if (!File.Exists(p))
{
fileUpload.PostedFile.SaveAs("C:\\Data\\IronElements\\Upload\\AUMData\\Schema\\AUMSchema.xlsx");
}
}
읽기 및 쓰기 권한이 있습니다. – Sravanthi
ASP.NET 프로세스가 실행중인 계정에 대한 사용 권한이 있는지 확인하십시오. 아, 그리고 그것이 당신이 생각하는 계정으로 돌아가고 있는지 확인하십시오. – JohnFx
좋습니다. 이것은 좋은 생각이 아니지만 시도해보십시오. 해당 폴더의 Everyone 역할에 읽기/쓰기 권한을 할당하고 어떤 일이 발생하는지 확인하십시오. 그 후 업로드가 이루어져야합니다. – Davita