Web Hosting Forum | Lunarpages

Author Topic: How to delete file?  (Read 22032 times)

Offline Lucky:)

  • Space Explorer
  • ***
  • Posts: 7
How to delete file?
« 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: [Select]
FileInfo fi = new FileInfo(filename));
 if (fi.Exists)
 {
   fi.Delete();
 }

How to delete file in programmatically?


websky19

  • Guest
Re: How to delete file?
« Reply #1 on: December 04, 2012, 02:38:14 AM »
I have also no ideea unless you provide more info, or seeing your code.

Offline annaharris

  • Spacescooter Operator
  • *****
  • Posts: 46
    • PHP Development Comapny
Re: How to delete file?
« Reply #2 on: December 27, 2012, 01:55:04 AM »
 I think file_delete() function can help you delete the file. But you should give detailed code so we can provide you suitable answer.

 

Share |