Sometime it is requirment that we should delete files once user have downloaded it.
This requirment is due to remove load on server.
Here I am writing the code that will allow user to delete the
file from server once the file is downloaded on the client’s machine.
To achieve this use following code:
private void DownloadAndDeleteFile()
{
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=testFile.txt");
Response.WriteFile(Server.MapPath("~/Documents/testFile.txt"));
Response.Flush();
System.IO.File.Delete(Server.MapPath("~/Documents/testFile.txt"));
Response.End();
}
Cheers!!!!!!!!!!!!!!!!
This requirment is due to remove load on server.
Here I am writing the code that will allow user to delete the
file from server once the file is downloaded on the client’s machine.
To achieve this use following code:
private void DownloadAndDeleteFile()
{
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=testFile.txt");
Response.WriteFile(Server.MapPath("~/Documents/testFile.txt"));
Response.Flush();
System.IO.File.Delete(Server.MapPath("~/Documents/testFile.txt"));
Response.End();
}
Cheers!!!!!!!!!!!!!!!!
Comments
Post a Comment