Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a server file on client machine...

Status
Not open for further replies.

brucegonewild

Programmer
Jan 25, 2008
22
CA
Hi there,
My users generate certain reports through our website. Once they're done creating these reports, they need to export these reports back to their local box. So what I need to do is:
1. Create a temp file and write the contents of the report to this file
2. Get user to "Save" this temp file to their local drive so they can later on open/print/modify the file.

As for writing to this temp file, I simply use: System.IO.Path.GetTempFileName() and I write the content of the report to it.

My problem is how do I get the users to actually save this file in their local machine?

Just to give you a background, the user clicks on a button saying "Export Report". The next thing, the report gets saved on a temp file in server. The last step should prompt the user to save the file to their local box...

Any help is MUCH appreciated...

cheers!
 
after the file is saved you then need to open the report in a stream. convert the stream to a byte array. close the file and delete the report on the server. then write the bytes to the response stream with the appropriate headers. use a generic handler (ashx) to do this, not a webform.

for examples google asp.net generic handler, or open image from database. while this is getting a image from a db instead of a file from the server the concepts are the same.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top