Return server side file to client

Discussion in '.NET' started by spoofie, Apr 29, 2008.

  1. spoofie

    spoofie

    Joined:
    Apr 9, 2008
    Messages:
    6
    Hello,

    My question is the following:
    In my current project I need to generate a server side document. This is no problem, I have completed this code.
    When the exporting is done I have a physical path on the server. For example: c:\inetpub\wwwroot\myapp\myreports\resume1256.docx

    Now I want to send this file back to the client so he/she sees the download dialog box.

    How can this be done ?

    //edit
    What I have so far:
    string fn = resumeBuilder.CreateDocument();
    FileInfo file = new FileInfo(fn);
    string fileName = file.Name;
    string test = Server.MapPath(fileName);
    Response.Clear();
    Response.ContentType = "application/vnd.openxmlformats";
    Response.WriteFile(fileName);
    Response.End();

    fn gets the value: c:\inetpub\wwwroot\myapp\myreports\resume1256.docx
    fileName gets the value: resume1256.docx
    test gets the same value as fn

    An exception is thrown with the message: could not find file: c:\inetpub\wwwroot\myapp\myreports\resume1256.docx

    I guess it has something to do with that path. It probably needs to be virtual instead of physical, right ?

    Thanx in advance,

    Kind regards,

    Spoofie
    Last edited: Apr 29, 2008
    spoofie, Apr 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jrefactors@hotmail.com
    Replies:
    0
    Views:
    430
    jrefactors@hotmail.com
    Jan 4, 2005
  2. jrefactors@hotmail.com
    Replies:
    1
    Views:
    6,264
  3. Boss302
    Replies:
    0
    Views:
    1,028
    Boss302
    Nov 21, 2006
  4. Bogdan
    Replies:
    2
    Views:
    639
    Bogdan
    Jun 9, 2008
  5. jrefactors@hotmail.com
    Replies:
    0
    Views:
    154
    jrefactors@hotmail.com
    Jan 4, 2005
Loading...

Share This Page