如何使用文本框输入检查文本文件内容 [英] how to check text file content with textbox input

查看:76
本文介绍了如何使用文本框输入检查文本文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi guys

我有一个文本文件,例如:test.txt

i have a text file for example: test.txt

test.txt数据是:

test.txt data is:

123

321

456

我有一个文本框我在文本框中输入321,我想要显示消息已经321或123或456 

i have a textbox i input 321 in textbox , i want show message already 321 or 123 or 456 

检查文本文件行 

check textfile lines 

推荐答案

调整并尝试这样的片段:

Adjust and try a fragment like this:

bool already_exists = File.ReadLines( @"C:\MyFolder\test.txt" ).Any( s => s.Trim().Equals( textBox1.Text.Trim(), StringComparison.InvariantCultureIgnoreCase ) );
if( already_exists) MessageBox.Show( textBox1.Text + " already exists.");


这篇关于如何使用文本框输入检查文本文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆