File download and file comparison

Source: Internet
Author: User
Tags try catch

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.