Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all. i am trying to delete one of file in my drive but it is not deleting this is my code written in button click event.

try
       {
           //System.IO.File.Delete(@"E:\sasi\ss");
           string path = @"e:\sasi\delt.doc";
           FileInfo myfileinf = new FileInfo(path);
           myfileinf.Delete();

           Response.Write("<script>alert('deleted')</script>");
       }
       catch (Exception  ex)
       {

           Label l = new Label();
           l.Text = ex.Message;
           Form.Controls.Add(l);
       }
Posted
Updated 2-Feb-11 15:10pm
v2

1 solution

I assume this code runs in the user context of the IIS. And that user probably doesn't have enough permissions to delete a file in that directory.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900