怎么判断某一文本中存在某一字符串
如何判断某一文本中存在某一字符串
例如我想查1.txt文本中是否存在"steven" 这个字符串,请问代码怎样写
------解决方案--------------------
读出来
例如我想查1.txt文本中是否存在"steven" 这个字符串,请问代码怎样写
------解决方案--------------------
读出来
- C# code
string strfromtxt = File.ReadAllText(@"C:\1.txt", Encoding.GetEncoding("GB2312")); if (strfromtxt.Contains("steven")) { MessageBox.Show("存在steven"); } else { MessageBox.Show("不存在steven"); }