amitshrivas 0 Light Poster

Hello to all..plz help me in this plzzzzzzzzzzzzz
i want to view/download a files from production server and after downloading i want to delete the same file from 2 places i.e from (database and one Uploaded folder in server).
i have 2 quries:

1: View Only ?
i have this code to view a file but it won't work for .xls files

Response.Clear();
   Response.AppendHeader("content-disposition", "inline;   
   filename=" + filename);
   Response.ContentType = conttype;
   Response.TransmitFile(Server.MapPath("~") + @"\Schedule\" + 
   filename);
   Response.End();
   Response.Flush();

this code works perfectly for .txt and .doc file but wont work for .xls means This will show open/Save Filedialog box which i dont want to see if i click on View Link

2: i want to download a fle from production server.
and the code i have written is

Response.Clear();
     Response.AppendHeader("content-disposition", "attachment; filename="+ filename);
        Response.ContentType = cont;
        string filepath = Server.MapPath("~") + @"\Schedule\" + filename;
        Response.WriteFile(filepath);
       
//        DeletRecordFromDatabase();
//        File.Delete(filepath);
//        LoadSchedule();
        Response.End();
        
        Response.Flush();

please read the code carefully..
specially in between this

Response.WriteFile(filepath);
       
//        DeletRecordFromDatabase();
//        File.Delete(filepath);
//        LoadSchedule();
        Response.End();
Response.Flush();

the commented part are the functions through which i will delete the file form Database,from Folder and Reload all the fresh data from database..to gridview
but when i click on Download link then it will not show the Open/Save Dialog box rather it will delete the file form database and from folder too.
and when i write the code something like this

Response.WriteFile(filepath);
        Response.End();
//        DeletRecordFromDatabase();
//        File.Delete(filepath);
//        LoadSchedule();
Response.Flush();

then it will show the Open/Save Dialog box but will not delete the data from database and from folder..

please help its urgent..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.