asp.net 下载网页源代码
来源:互联网 发布:电视信源如何选择网络 编辑:程序博客网 时间:2024/05/16 12:12
//指定下载的文件名string fileName = "网页源代码.txt";//客户端保存的文件名//指定下载的url地址:http://www.baidu.comstring url = "http://www.baidu.com";WebClient client = new WebClient();用于传递url资源的方法client.Encoding = Encoding.UTF8;byte[] html = client.DownloadData(url);string strPath = MapPath("~/html");定义储存路径if(!Directory.Exists(strPath)){ Directory.CreateDirectory(strPath);}string savePath = Path.Combine(strPath,"html.txt");//下载文件的详细地址using(FileStream fsSave = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)){ fsSave .Write(html, 0, html.Length);}//义字符流的形式下载文件 FileStream fs = new FileStream(savePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream";//通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End();
0 0
- asp.net 下载网页源代码
- Asp.net 获取网页源代码
- asp.net源代码下载网站
- ASP.NET:源代码下载基地
- ASP.NET:源代码下载基地
- ASP.NET MVC源代码下载。
- 用asp.net c# 获取网页源代码
- 用asp.net c# 获取网页源代码
- ASP.NET MVC 源代码可以下载了
- 用asp.net(c#)获取网页源代码(两种方法)
- 三种asp.net 抓取网页源代码,推荐方法一
- ASP网页计数器源代码
- jQuery操作asp.net treeview控件实例源代码下载
- 能下载整站asp.net源代码的地方
- asp.net源代码下载网站、C#/VB代码转换网站
- asp.net调用摄像头示例程序源代码下载
- .NET获取网页源代码
- C#、ASP.NET、黑客技术、网页设计、教程下载大全
- XPath语法速记
- ros与下位机通信常用的c++ boost串口通信
- JQuery
- 关于struts标签库的一些积累
- 测试用例设计——WEB通用测试用例
- asp.net 下载网页源代码
- iOS开发之isEqual与hash!
- .NET/ASP.NET MVC(模块化开发AraeRegistration)
- 计算机系统学习2:程序的机器级表示之函数调用
- 在windows平台下使用visual studio2013和opencv3.0.0配置一个开发环境
- 游戏入口点GameEntryPoint
- Angular 2的组件样式
- 一篇对大数据深度思考的文章,让你认识并读懂大数据
- 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置