Delete Temporary File From ASP.Net

Hello Frd's

There are often required to delete temp file which created during asp.net pages hit.you can delete this temp files either mannualy or by coding.

to delete temp file using Coding follow the below Step.

Store Temp File Path in Session["pdfpath"]


Write below code in global.aspx


void Session_End(object sender, EventArgs e) {
if (System.IO.File.Exists(Session["pdfpath"].ToString()))System.IO.File.Delete(Session["pdfpath"].ToString()); }

in web.config
<sessionState mode="InProc" timeout="20">
sessionState>




this Code delete your temp file.

Please do not forgot to comment on articles.


Posted in | 0 comments