Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 16, 2012, 05:32:26 PM

Pages: [1]   Go Down
  Print  
Author Topic: How to delete file?  (Read 5235 times)
Lucky:)
Space Explorer
***
Offline Offline

Posts: 7


« on: March 07, 2011, 10:00:58 PM »

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.

Code:
FileInfo fi = new FileInfo(filename));
 if (fi.Exists)
 {
   fi.Delete();
 }

How to delete file in programmatically?

Logged
Pages: [1]   Go Up
  Print  
 
Jump to: