C#讀取host文件代碼
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Text; using System.Windows.Forms;namespace 讀取host文件 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { string str; StreamReader sr = new StreamReader(@"C:\windows\system32\drivers\etc" + "\\hosts", false); str = sr.ReadToEnd().ToString(); sr.Close(); this.richTextBox1.Text = str;///讀取 }
}
}
@"C:\windows\system32\drivers\etc" + "\hosts"文件路徑</pre>
本文由用戶 xb3b 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!