Web Hosting Forum | Lunarpages


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



Login with username, password and session length
September 02, 2014, 09:14:24 AM

Pages: [1]   Go Down
  Print  
Author Topic: How to delete file?  (Read 19094 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
websky19
Guest
« Reply #1 on: December 04, 2012, 02:38:14 AM »

I have also no ideea unless you provide more info, or seeing your code.
Logged
annaharris
Spacescooter Operator
*****
Offline Offline

Posts: 49


WWW
« 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.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: