Hi All,
I have user uploaded file on my server. Now I need to delete those files.
When I'm using System.IO methods I'm getting System.UnauthorizedAccessException
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 'D:\mywebsite\httpdocs\myfolder\1.jpg' is denied.
FileInfo fi = new FileInfo(filename)); if (fi.Exists) { fi.Delete(); }
How to delete file in programmatically?
The path starts in the root folder of the localhost server not the computers hard drive.
System.UnauthorizedAccessException is a security restriction...
It has to be that way because when you finally start using a professional web host you will be sharing that web servers hard drive with hundreds if not thousands of other people and you don't want them being able to delete your files do you?