File.Delete does not work
-
I want to delete some files from my application. For this I am using System.IO.File.Delete. It gives me error "Access to Path 'C:\EmployeeData\EmployeeJun.htm' is denied." I did find some articles explaining that account should have privileges to the path or file. I verified that ASPNET account had read and write permission to the folder and to the file (inherited permission from parent). Any idea what is missing here. In addition, I have web service in application that can delete the same file from within the application. In case account is missing permissions to the file, how File.Delete can delete the same file from web service? Please explain. Thanks in advance.
-
I want to delete some files from my application. For this I am using System.IO.File.Delete. It gives me error "Access to Path 'C:\EmployeeData\EmployeeJun.htm' is denied." I did find some articles explaining that account should have privileges to the path or file. I verified that ASPNET account had read and write permission to the folder and to the file (inherited permission from parent). Any idea what is missing here. In addition, I have web service in application that can delete the same file from within the application. In case account is missing permissions to the file, how File.Delete can delete the same file from web service? Please explain. Thanks in advance.
Your ASP.NET application cannot access files above the application root. This is by design.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I want to delete some files from my application. For this I am using System.IO.File.Delete. It gives me error "Access to Path 'C:\EmployeeData\EmployeeJun.htm' is denied." I did find some articles explaining that account should have privileges to the path or file. I verified that ASPNET account had read and write permission to the folder and to the file (inherited permission from parent). Any idea what is missing here. In addition, I have web service in application that can delete the same file from within the application. In case account is missing permissions to the file, how File.Delete can delete the same file from web service? Please explain. Thanks in advance.
-
Your ASP.NET application cannot access files above the application root. This is by design.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Thank you for reply. File is not above the application root but under application root. Like I stated before, I can delete the file from the web service running on the server (personal web server here) and invoked from the application. File (also created from the application) has Read, Write and Read & Execute permissions already. I just tried giving Modify permission to the file and delete it from aspx page. It worked. I am confused!! Kubben, what for is IIS_WPG account?
-
Thank you for reply. File is not above the application root but under application root. Like I stated before, I can delete the file from the web service running on the server (personal web server here) and invoked from the application. File (also created from the application) has Read, Write and Read & Execute permissions already. I just tried giving Modify permission to the file and delete it from aspx page. It worked. I am confused!! Kubben, what for is IIS_WPG account?
IIS_WPG is the iis worker process group. Any user or identity that you are trying to use to be the indentity of the application pool also need to be in the IIS_WPG group. Thinking about it aspnet user would already be in this group. Still the identity of your app pool it probably network service. That group most likely doesn't have rights to delete the file. Ben