نمایش نتایج 1 تا 2 از 2

نام تاپیک: اطلاعات چند فایل با هم

  1. #1
    کاربر دائمی
    تاریخ عضویت
    مرداد 1387
    محل زندگی
    مشهد
    سن
    39
    پست
    116

    اطلاعات چند فایل با هم

    با سلام
    می خواهم اطلاعات چند فایل با هم را در یک 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
    }

  2. #2
    کاربر دائمی
    تاریخ عضویت
    فروردین 1386
    محل زندگی
    آستارا-تهران
    پست
    357

    نقل قول: اطلاعات چند فایل با هم

    چون دستور openFileDialog2.OpenFile() هر دفعه فایل اولی رو که انتخاب شده رو باز می کنه
    به جای
    using (StreamReader sr = newStreamReader(myStream))

    اینجوری بنویس


    using
    (StreamReader sr = newStreamReader(fileName))

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •