با سلام
می خواهم اطلاعات چند فایل با هم را در یک textboc نشان دهم ولی فقط اطلاعات یکی از آنها را به من نشان می دهد.لطفا کمک کنید
string str;
int len;
Stream myStream;
// OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog2.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in openFileDialog2.FileNames)
{
if ((myStream = openFileDialog2.OpenFile()) != null)
{
// Insert code to read the stream here.
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = newStreamReader(myStream))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("TEL") == true)
{
len = line.Length - 1;
str = line.Substring(4, len - 3);
textBox1.Text = textBox1.Text+ "- " + str;
}
elseif (line.Contains("Date") == true)
{
len = line.Length - 1;
str = line.Substring(5, len - 4);
textBox1.Text = textBox1.Text +" "+ str;
line = sr.ReadLine();
textBox1.Text = textBox1.Text + "\r\n" + line;
}
//textBox1.Text = textBox1.Text + "\r\n" + line;
}
}
}
catch (Exception err)
{
// Let the user know what went wrong.
MessageBox.Show(err.Message);
}
myStream.Close();
}
}//if1
}