Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

Retrieving the browsed path in the file dialog & save it using the browsed path in future

By using the code, it would save the pdf file to the browsed location in the file dialog

just if possible if it could anyhow retrieve the browsed location (from the file dialog) to a textbox

and use path in the textbox and save the pdf file back to this path (from the textbox) ?

private static void SetResponse(string fileName)
    {
        string attachment = "attachment; filename=" + fileName + ".pdf";
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.AddHeader("content-disposition", attachment);
        HttpContext.Current.Response.ContentType = "pdf";
        HttpContext.Current.Response.AddHeader("Pragma", "public");
    }

  protected void btnSave_Click(object sender, EventArgs e)
    {
      

        FileStream fs = File.OpenRead(Server.MapPath("~/Scripts/1.pdf"));

        byte[] buffer = new byte[(int)fs.Length];
        fs.Read(buffer, 0, (int)fs.Length);
        fs.Close();
        SetResponse("pdfName");
        HttpContext.Current.Response.BinaryWrite(buffer);
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.Close();

        dNextCopyRunningNumber += 1;

        bSaved = true;


    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doramail05

ASKER

I've requested that this question be deleted for the following reason:

not much response
There is not much response because the only answer is #a39865092