locked
delete a pdf file RRS feed

  • Question

  • User-1651858287 posted

    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);

                }

    Tuesday, January 23, 2018 2:49 PM

All replies

  • User-492460945 posted

    Hi SweetSteal,

    Are you getting any error or exception while running your code? Please let me know if any error.

    -Thanks,

    Rajesh

    Wednesday, February 28, 2018 3:05 PM