資源簡介
C#,VS2010,獲取網頁源碼,并保存到txt文件,可以顯示到richtextbox

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
namespace?網頁源碼獲取1
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????string?http?=?this.textBox1.Text;
????????????GetHttp?get?=?new?GetHttp();
????????????this.richTextBox1.Text?=?get.getDataFromUrl(http).ToString();
????????}
????????#region?導出數據
????????///?
????????///?導出數據
????????///?
????????///?
????????///?
????????///?
????????private?bool?TxtExport(string?FullFileName?string?TextAll)
????????{
????????????if?(File.Exists(FullFileName))
????????????{
????????????????File.Delete(FullFileName);?
????????????}
????????????FileStream?fs?=?new?FileStream(FullFileName?FileMode.CreateNew);
????????????fs.Close();
????????????StreamWriter?sw?=?new?StreamWriter(FullFileName?true?Encoding.Default);???//該編碼類型不會改變已有文件的編碼類型
????????????sw.WriteLine(TextAll);
????????????sw.Close();
????????????return?true;
????????}
????????#endregion
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????string?http?=?this.textBox1.Text;
????????????GetHttp?get?=?new?GetHttp();
????????????this.richTextBox2.Text?=?get.GetHttpCountent(http).ToString();
????????}
????????private?void?button3_Click(object?sender?EventArgs?e)
????????{
????????????string?http?=?this.textBox1.Text;
????????????GetHttp?get?=?new?GetHttp();
????????????TxtExport(“D:\\1.txt“?get.getDataFromUrl(http).ToString());
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2030??2013-05-10?12:30??網頁源碼獲取1\Form1.cs
?????文件???????5462??2013-05-10?12:30??網頁源碼獲取1\Form1.Designer.cs
?????文件????????500??2013-05-09?20:41??網頁源碼獲取1\Program.cs
?????文件???????3735??2013-05-09?21:10??網頁源碼獲取1\網頁源碼獲取1.csproj
?????文件???????5817??2013-05-10?12:30??網頁源碼獲取1\Form1.resx
?????文件???????6311??2013-05-10?10:56??網頁源碼獲取1\GetHttp.cs
?????文件???????6347??2013-05-10?10:55??網頁源碼獲取1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????180??2013-05-10?10:53??網頁源碼獲取1\obj\x86\Debug\網頁源碼獲取1.Form1.resources
?????文件????????180??2013-05-09?21:10??網頁源碼獲取1\obj\x86\Debug\網頁源碼獲取1.Properties.Resources.resources
?????文件????????304??2013-05-10?10:53??網頁源碼獲取1\obj\x86\Debug\GenerateResource.read.1.tlog
?????文件????????706??2013-05-10?10:53??網頁源碼獲取1\obj\x86\Debug\GenerateResource.write.1.tlog
?????文件??????30208??2013-05-10?10:55??網頁源碼獲取1\obj\x86\Debug\網頁源碼獲取1.pdb
?????文件??????12288??2013-05-10?10:55??網頁源碼獲取1\obj\x86\Debug\網頁源碼獲取1.exe
?????文件???????1147??2013-05-10?10:55??網頁源碼獲取1\obj\x86\Debug\網頁源碼獲取1.csproj.FileListAbsolute.txt
?????文件???????4440??2013-05-10?09:50??網頁源碼獲取1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7897??2013-05-10?10:17??網頁源碼獲取1\obj\x86\Debug\ResolveAssemblyReference.cache
?????文件??????12288??2013-05-10?10:55??網頁源碼獲取1\bin\Debug\網頁源碼獲取1.exe
?????文件??????30208??2013-05-10?10:55??網頁源碼獲取1\bin\Debug\網頁源碼獲取1.pdb
?????文件??????11600??2013-05-10?10:55??網頁源碼獲取1\bin\Debug\網頁源碼獲取1.vshost.exe
?????文件????????490??2010-03-17?22:39??網頁源碼獲取1\bin\Debug\網頁源碼獲取1.vshost.exe.manifest
?????文件???????1424??2013-05-09?20:41??網頁源碼獲取1\Properties\AssemblyInfo.cs
?????文件???????5612??2013-05-09?20:41??網頁源碼獲取1\Properties\Resources.resx
?????文件???????2886??2013-05-09?20:41??網頁源碼獲取1\Properties\Resources.Designer.cs
?????文件????????249??2013-05-09?20:41??網頁源碼獲取1\Properties\Settings.settings
?????文件???????1102??2013-05-09?20:41??網頁源碼獲取1\Properties\Settings.Designer.cs
?????目錄??????????0??2013-05-10?12:31??網頁源碼獲取1\obj\x86\Debug\TempPE
?????目錄??????????0??2013-05-10?12:31??網頁源碼獲取1\obj\x86\Debug
?????目錄??????????0??2013-05-10?12:31??網頁源碼獲取1\obj\x86
?????目錄??????????0??2013-05-10?12:31??網頁源碼獲取1\bin\Debug
?????目錄??????????0??2013-05-10?12:31??網頁源碼獲取1\obj
............此處省略6個文件信息
評論
共有 條評論