Question

I have a ASP.net page which writes a file to the local disk.

I want to present the user a Save File dialog box and allow him to set the path to the folder.

I know code like below can be used;

Response.Clear();
Response.ContentType = "text/csv";
Response.AddHeader( "Content-Disposition", "attachment;filename=\"report.csv\"" );
// write your CSV data to Response.OutputStream here
Response.End();

But it fixes filepath.

I need to capture the filepath that the user selects. Is that possible in ASP.net?

Thanks.

Était-ce utile?

La solution

it does not work like that from a web page, you have to initiate the download suggestiong a target file name then the user can override your suggested file name and select any folder or filename he likes and your content will be saved in that location.

you do nothing with a local path which only makes sense on the client machine on the server side of ASP.NET application.

Autres conseils

I need to capture the filepath that the user selects. Is that possible

No. Your web server presents a file to the client, where the client has the option to save this file.

In what way would the path the client saves this file be interesting to the server?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top