简体   繁体   中英

Open File Dialog Asp.Net

I am creating an excel report in vb.net using the office interop. When the report is completed I am saving the excel file on the C drive. The users have asked to save file anywhere they want not just the c drive. Can someone give me some code to popup an opend file dialog in asp.net?

I want the dialog to popup in a saveAs in ASP.NET. I know how to do it in win forms, but I am creating an excel report in asp.net and calling the worksheet objects SaveAs property that excepts a fileName. So right now I just hardcode a file name in there. The users want to choose a file location

I think what you want is actually rather simple.

You can't save a file to the user's computer due to security restrictions (would you want a website saving a file to your computer?)

What you need to do is:

  1. Complete report
  2. Save report file to location on server , IE (.../myWebsite/files/GUID/myReport.rpt)
  3. Display link on next screen pointing to the report file

Doing this the user can right-click and save the file to wherever they want on their computer.

You can clean up these files on whatever schedule you would like.

Assuming you are actually talking about a desktop, winforms app then you can use the built in FileSaveDialog.

Official documentation is here:

but there are tons of tutorials explaining it out there:

You can server files with the Open / Save dialog by using Response.TransmitFile() .

The user is then presented with a save as dialog where they can choose the filename and the location on their computer.

You normally do this inside a HttpHandler . A simple one is described here:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM