3
Answers

Split??

Sin Yee

Sin Yee

13y
1.6k
1
Hey...i am doing Split now.
But, my split method cannot function well. I want split my text file content from horizontal to vertical. But, my output always got problem.

or example

my text file content is like this..
eg.
1 2 3 4 5 
2 3 4 5

my output wants like this
1     2
2     3
3     4
4     5
5
but my output always give me like this...this is not i want.
1
2
3
4
5
2
3
4
5

So, how to solve it? And how to show it in the textbox?? Who can help me..?
C# Syntax (Toggle Plain Text)
  1. StringBuilder sb = new StringBuilder();
  2. string line;
  3. string Temp = " ";
  4.  
  5. if (File.Exists(fileOpen.FileName))
  6. {
  7.  
  8. StreamReader file = null;
  9. try
  10. {
  11. file = new StreamReader(fileOpen.FileName);
  12. while ((line = file.ReadLine()) != null)
  13. {
  14. sb.AppendLine(line);
  15. }
  16. // textBox1.Text = sb.ToString();
  17.  
  18.  
  19.  
  20. foreach (string lines in File.ReadAllLines(fileOpen.FileName))
  21. {
  22. string[] Split = lines.Split(new string[] { " ", "\n", "\r", "\t" }, StringSplitOptions.RemoveEmptyEntries);
  23.  
  24. foreach (string Splits in Split)
  25. {
  26. Temp = Temp + "\n" + Split;
  27. }
  28.  
  29. //show line by line after split
  30. MessageBox.Show(Temp, "read by line");
  31. }
  32.  
  33.  
  34.  
  35.  
  36. }
this is the coding..hope someone can help me?
Answers (3)