如何使用c#.net读取文本文件中的特定文本? [英] How to read particular text in text file using c# .net?
本文介绍了如何使用c#.net读取文本文件中的特定文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我的文本文件中写的一些文字: -
ABC许可证版本1.0
验证天数= 10
MAC地址= xxxxxxxxxxxx
如何使用c#读取文本文件中的特定文本.net?
我必须在按钮点击事件上只读这个文本xxxxxxxxxxxx。
请帮忙我。
在此先感谢。
Ankit Agarwal
软件工程师
Hello,
Some Text written in my text file:-
ABC Licence Version 1.0
Validated Days=10
MAC Address=xxxxxxxxxxxx
How to read particular text in text file using c# .net?
I have to read only this text xxxxxxxxxxxx on button click event.
Please help me.
Thanks in Advance.
Ankit Agarwal
Software Engineer
推荐答案
假设您的文件位于dekstop,名称为test.txt
Suppose your file is at dekstop with name test.txt
System.IO.StreamReader streamReader = new System.IO.StreamReader("C:\\Users\\PuneetGoel\\Desktop\\test.txt");
string text = streamReader.ReadToEnd();
string macAddress = text.Split('=')[2].ToString();
streamReader.Close();
这篇关于如何使用c#.net读取文本文件中的特定文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文