I tested it many times and found a lot of information on the Internet, but I didn't find a desired one, such as the configuration file and heads. all the add header files have been tried, but they are still not implemented. All errors are reported. Finally, we finally found a simple implementation method:
1. First download msxml2.dll
2. client code
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "MsXmlTest. aspx. cs" Inherits = "MyWeb. MsXmlTest" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
<Style type = "text/css">
# Txt1
{
Width: 466px;
Height: 51px;
}
# Txt2
{
Width: 464px;
Height: 51px;
}
</Style>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Input type = "text" id = "txt1" runat = "server"/> <br/>
<Input type = "text" id = "txt2" runat = "server"/> <br/>
<Asp: Button ID = "btn" runat = "server" Text = "MsXml test" onclick = "btn_Click"/>
</Div>
</Form>
</Body>
</Html>
2. Implementation Method
/// <Summary>
/// Download the file in the specified url path
/// </Summary>
/// <Param name = "url"> specify the url path </param>
/// <Param name = "filename"> path to be saved </param>
/// <Param name = "type"> Request Method (GET or POST) </param>
Private void Down (string url, string filename, string type)
{
XMLHTTP xmlhttp = new XMLHTTPClass ();
Xmlhttp. open (type, url, false, null, null );
Xmlhttp. send ("");
If (xmlhttp. readyState = 4)
{
If (xmlhttp. status = 200)
{
Byte [] mybyte = (byte []) xmlhttp. responseBody;
FileStream fs = new FileStream (filename, FileMode. Create, FileAccess. Write );
Fs. Write (mybyte, 0, mybyte. Length );
Fs. Close ();
}
}
}
3. Call
Protected void btn_Click (object sender, EventArgs e)
{
// Down ("http://list.image.baidu.com/t/image_category/galleryimg/wallpaper/human/han_gmn.jpg", "E: // B .jpg", "GET ");
Down(this.txt 1. Value, this.txt 2. Value, "GET ");
}