Last post Feb 28, 2018 03:05 PM by rajesh93180
Member
13 Points
57 Posts
Jan 23, 2018 02:49 PM|sweetSteal|LINK
The supervisor can create a pdf file from a database.
The problem is after the file is created others user can access the pdf directly.
At url.pdf.
I want to murder url.pdf after 30 minutes. Thus no one can access it since its does not live anymore.
I do not have any experience doing this any ideas and suggestions would help.
Thanks.
//create file code above
//open file
string path = ResolveClientUrl("~/Appraisal/" + Empl.SelectedValue + ".pdf");
string encodedPath = System.Web.HttpUtility.JavaScriptStringEncode(path, true);
ClientScript.RegisterStartupScript(this.GetType(), "open", "window.open(" + encodedPath + ", '_blank');", true);
}
//delete file
string location = Server.MapPath("~/Appraisal");
string delFile = location + "/" + Empl.SelectedValue + ".pdf";
try
{
File.Delete(delFile);
catch (IOException iox)
Response.Write(iox.Message);
Participant
1644 Points
792 Posts
Feb 28, 2018 03:05 PM|rajesh93180|LINK
Hi SweetSteal,
Are you getting any error or exception while running your code? Please let me know if any error.
-Thanks,
Rajesh
Member
13 Points
57 Posts
delete a pdf file
Jan 23, 2018 02:49 PM|sweetSteal|LINK
The supervisor can create a pdf file from a database.
The problem is after the file is created others user can access the pdf directly.
At url.pdf.
I want to murder url.pdf after 30 minutes. Thus no one can access it since its does not live anymore.
I do not have any experience doing this any ideas and suggestions would help.
Thanks.
//create file code above
//open file
string path = ResolveClientUrl("~/Appraisal/" + Empl.SelectedValue + ".pdf");
string encodedPath = System.Web.HttpUtility.JavaScriptStringEncode(path, true);
ClientScript.RegisterStartupScript(this.GetType(), "open", "window.open(" + encodedPath + ", '_blank');", true);
}
//delete file
string location = Server.MapPath("~/Appraisal");
string delFile = location + "/" + Empl.SelectedValue + ".pdf";
try
{
File.Delete(delFile);
}
catch (IOException iox)
{
Response.Write(iox.Message);
}
Participant
1644 Points
792 Posts
Re: delete a pdf file
Feb 28, 2018 03:05 PM|rajesh93180|LINK
Hi SweetSteal,
Are you getting any error or exception while running your code? Please let me know if any error.
-Thanks,
Rajesh
Mark as answer if you find this post helpful.