Response.WriteFile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • christof

    Response.WriteFile

    I have situation like this, a file is made on server, then the clinet is
    downloading it to his machine and afterwards i wish to delete file on
    the server, unfortunately if i'm doing it like that, it doesn't work:



    Response.Append Header("content-disposition","a ttachment;
    filename="+txtF ileName.Text);
    Response.Conten tType = "applicatio n/x-msdownload";
    Response.WriteF ile((string)Vie wState["backupFile "]);

    File.Delete((st ring)ViewState["backupFile "]);

    - the file is deleted before this dialog launches, if i ommit the last
    line dialog is shown, client saves the file, and it's fine.

    How to force my app to wait before user saves the file and right then
    when it's done - delete the file on server?

    Thx
  • Erik Funkenbusch

    #2
    Re: Response.WriteF ile

    On Sun, 19 Mar 2006 13:56:09 +0100, christof wrote:
    [color=blue]
    > How to force my app to wait before user saves the file and right then
    > when it's done - delete the file on server?[/color]

    You can't.

    Your best bet is create the file in some temporary directory, then every so
    often delete all the files in that directory that are older than a certain
    amount of time (this prevents you from possibly deleting files that have
    sent requests but have not actually started downloading yet).

    Comment

    Working...