using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.Storage;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
string path = @"c:\users\hhkk\documents\visual studio 2012\Projects\WindowsFormsApplication2\WindowsFormsApplication2\TextFile1.txt";
string ch = textbox1.Text;
StreamReader sr = new StreamReader(path);
string line = sr.ReadLine();
while (line != null)
{ if (line != null && line.Contains(ch))
{
textbox1.Text = line;
break;
}
line = sr.ReadLine();
}
if (line == null)
{
textbox2.Text = "找不到相应的数据";
}
sr.Close();
}
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.Storage;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
string path = @"c:\users\hhkk\documents\visual studio 2012\Projects\WindowsFormsApplication2\WindowsFormsApplication2\TextFile1.txt";
string ch = textbox1.Text;
StreamReader sr = new StreamReader(path);
string line = sr.ReadLine();
while (line != null)
{ if (line != null && line.Contains(ch))
{
textbox1.Text = line;
break;
}
line = sr.ReadLine();
}
if (line == null)
{
textbox2.Text = "找不到相应的数据";
}
sr.Close();
}
}
}
