C#读取host文件代码


本文摘自PHP中文网,作者大家讲道理,侵删。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

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"文件路径

相关阅读 >>

c#将文件上传、下载(以二进制流保存到数据库)

c#查找字符串的所有排列组合

c#实现图标锁定到windows任务栏或删除图标

c#操作mysql的工具类mysqlhelper

常用的c#类

二叉搜索树插入算法c#

c#读取host文件代码

c#自定读取配置文件类

c#中登陆账户使用的md5加密算法

c#访问sqlserver的工具类sqlserverhelper

更多相关阅读请进入《代码片段》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...