日期:2014-05-17 浏览次数:20937 次
using (StreamReader sr = new StreamReader("E:\\1.txt", System.Text.Encoding.Default)) { string TextStr; TextStr = sr.ReadToEnd().ToString(); sr.Close(); FormFind.txt = TextStr; }
public static string txt ; private void FormFind_Load(object sender, EventArgs e) { this.txtReadTxtStr.Text = txt; }
private void button3_Click(object sender, EventArgs e) { if (FDialog.ShowDialog()==DialogResult.OK) { string name = FDialog.SelectedPath; DirectoryInfo dir = new DirectoryInfo(name); DirectoryInfo[] dirs = dir.GetDirectories(); FileInfo[] flie = dir.GetFiles(); foreach (FileInfo fi in flie) { string val = fi.Extension; if (val == ".txt") { using (StreamReader sr = new StreamReader(fi.FullName, System.Text.Encoding.Default)) { string TextStr; TextStr = sr.ReadToEnd().ToString(); sr.Close(); Form1.txt += TextStr; } } } } }