C#写的一个下载文件的程序,下载的文件到本地后,里面含有HTML代码
1,我的服务器端有文本文件A,A中有内容“暗暗暗暗啊”,用程序下载保存到本地后,变成了“暗暗暗暗啊”还加以下的东东
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="test.aspx" id="Form1" enctype="multipart/form-data">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjAxMTUyNTc2MTt0PDtsPGk8MT47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpPDE+Oz47bDx0PEAwPDs7Ozs7Ozs7Ozs+Ozs+Oz4+Oz4+Oz7qxz0xvbD3qhZAPCcKnOVY5omIsA==" />
<input type="submit" name="Button1" value="Button" id="Button1" style="Z-INDEX: 101; LEFT: 344px; POSITION: absolute; TOP: 112px" /><input name="File1" id="File1" type="file" style="Z-INDEX: 102; LEFT: 528px; POSITION: absolute; TOP: 216px" />
</form>
</body>
</HTML>
为什么?为什么?为什么?
为什么?
为什么?
代码:
Response.AddHeader("Content-Disposition", "attachment;filename=" +System.Web.HttpUtility.UrlEncode(path+filename,System.Text.Encoding.UTF8));
Response.ContentType = ContentType;
Response.TransmitFile(path+filename);
Response.Flush();