Hi, now i want to print out the data from the text file. but, i face a problem in the output.the program give me the output is like this:

1 2:1

1 3:2

1 4:2

2 3:1

2 4:1

3 4:2

1 3:1

1 4:1

3 4:1

1 2:1

1 3:1

1 4:2

2 4:1

3 4:1
But, what i want is like this:
1 2:1
1 3:2
1 4:2
2 3:1
2 4:1
3 4:2
1 3:1
1 4:1
3 4:1
1 2:1
1 3:1
1 4:2
2 4:1
3 4:1

I don't want the space between the two lines. So, how to eliminate the space between the two lines

using (OpenFileDialog fileOpen = new OpenFileDialog())
            {
                String path = @"C:\Users\Fish\Desktop\fyp-coding\Combine1.txt";

                if (File.Exists(path))
                {
                    StreamReader f = null;

                    try
                    {
                        f = new StreamReader(path);

                        while ((read = f.ReadLine()) != null)
                        {
                            s1.AppendLine(read);
                        }
                          MessageBox.Show(s1.ToString().Trim());

Hope someone can help me..thanks ya..

Recommended Answers

All 2 Replies

Rather than AppendLine, use Append. Your variable read contains an endline character since that is how the ReadLine terminates the line.

while ((read = f.ReadLine()) != null)
{
   s1.Append(read);
}

if use append will be like this:
1 2:11 3:21 4:22 3:12 4:13 4:21 3:11 4:13 4:11 2:11 3:11 4:22 4:13 4:1
I have try this code already.But this is not what i want...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.