Let's start by saying how the front-end code implements file downloads:
<a href="template.xlsx"> template file Download </a>
Some files, such as exe,xls,zip files, the browser will pop up to save the file prompt box, some files, such as txt,img files, the browser is opened directly, the various browsers to their handling of different ways.
Code for the C # background implementation file download
1 protected voidBtndown_click (Objectsender, EventArgs e)2 {3 stringfilename = Server.MapPath ("File path");4 if(!file.exists (filename))5 {6Response.Write ("<script>alert (' File not present ');</script>");7 return;8 }9Response.ContentType ="application/x-zip-compressed";TenResponse.AddHeader ("content-disposition","attachment;filename="+ request.querystring["SOURCE_NC"]); One response.transmitfile (filename); A Response.End (); -}
File comparison:
To run a local executable using javascript: (ie browser only)
New ActiveXObject ("Wscript.Shell"). Run ("D:\\beyondcompare.exe");
File comparison tool can be used to pass the parameter: (ie browser only)
PARA1: Path to run the software, Para2: invalid, para3: First comparison file, Para4: Second contrast file
New ActiveXObject ("Wscript.Shell"). Run ("D:\\beyondcompare.exe d:\\1.txt d:\\comp1.txt d:\\comp1.txt");
Sometimes the browser may not respond, you can use try catch to catch the exception information
1 Try {2 New ActiveXObject ("Wscript.Shell"). Run ("D:\\beyondcompare.exe d:\\1.txt d:\\comp1.txt d:\\comp1.txt"); 3 }4 catch (e) {5 6 }
The IE Setup issue may be detected:
1. Turn on Internet Options-security-Custom Level
2. Change ActiveX controls and plugins to "enabled" in the following ActiveX
Ok
File download and file comparison