EFileTahi-A
Well-known member
Code:
StreamWriter strWriter = new StreamWriter(Application.StartupPath + "\\" + "bla.txt", false, System.Text.Encoding.BigEndianUnicode);
strWriter.WriteLine(textBox1.Text);
strWriter.WriteLine(textBox2.Text);
strWriter.WriteLine(textBox3.Text);
strWriter.WriteLine(textBox4.Text);
strWriter.WriteLine(textBox5.Text);
strWriter.WriteLine(textBox6.Text);
strWriter.WriteLine(textBox7.Text);
strWriter.WriteLine(textBox8.Text);
strWriter.Close();
This creates a text file with following input:
1
2
3
4
5
6
7
8
Ok, but I want to read every line to a specific string variable. Why the F. does this F. S. reads only a few lines? why is it skiping lines?
Code:
string sTemp1 = strReader.ReadLine(); //Assigns value 2
string sTemp2 = strReader.ReadLine(); //Assigns value 4
string sTemp3 = strReader.ReadLine(); //Assigns value 6
string sTemp4 = strReader.ReadLine(); //Assigns value 8
string sTemp5 = strReader.ReadLine(); //Null!
string sTemp6 = strReader.ReadLine(); //Null!
string sTemp7 = strReader.ReadLine(); //Null!
string sTemp8 = strReader.ReadLine(); //Null!
???
Strangely enough, this it reads the text file well if I assign the values to textboxes instead!
Code:
this.textBox1.Text = strReader.ReadLine(); //Assigns value 1
this.textBox2.Text = strReader.ReadLine(); //Assigns value 2
this.textBox3.Text = strReader.ReadLine(); //Assigns value 3
this.textBox4.Text = strReader.ReadLine(); //Assigns value 4
this.textBox5.Text = strReader.ReadLine(); //Assigns value 5
this.textBox6.Text = strReader.ReadLine(); //Assigns value 6
this.textBox7.Text = strReader.ReadLine(); //Assigns value 7
this.textBox8.Text = strReader.ReadLine(); //Assigns value 8
WHY!?
Well if needed it will be pleasure to upload the project...