c# - How to disable Download Prompt like 'do you want to open or save or save_as?' -


i'm trying download file located on internet site , know how webclient class.

but @ case site re-directed web address , therefore, i'm considering use process.start("url address before re-directed") avoid bit complexity download through re-directed web address. succeeded download file through re-directed web address.

however, i'm curious , want speed application removing intermediate steps if possible.

if approach through process.start("url address before re-directed"), download prompt shown ask users 'do want open? save? save_as?'.

and don't want download prompt shown , want save automatically utilize file in application.(if possible, want indicate location(path) saved.)

thank !

process.start("some url") telling os handle url. os sees url , gives default browser. default browser whatever configured do. process.start("some url") can not force default browser not show download prompt.

you looking httpwebrequest.allowautoredirect.

example msdn:

httpwebrequest myhttpwebrequest= (httpwebrequest)webrequest.create("http://www.contoso.com"); myhttpwebrequest.maximumautomaticredirections=1; myhttpwebrequest.allowautoredirect=true; httpwebresponse myhttpwebresponse=(httpwebresponse)myhttpwebrequest.getresponse();   

and of course want file:

using (var stream = myhttpwebresponse.getresponsestream()) {     using (var filestream = new filestream(filepath, filemode.create)) {         stream.copyto(filestream);     } } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -