Return server side file to client

Joined
Apr 9, 2008
Messages
6
Reaction score
0
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:

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top