So What I am trying to do it take a CSV file take what is in it and diplay it in a big textbox or txt file.

String[] lines = File.ReadAllText("**").Split(',');

                foreach (string line in lines)
                {
                        textBox1.Text = line;
                }

That is what I have so far. Issues is it reads it and puts it in the textbox but it deplays as

Hi
I
Am
Bob

But I want it to read 1 whole line then skip and so forth so it will read

Hi, I, Am, Bob

Then goes to row 2. Also can't figure out how to skip some columns and only look at like say column 3 and 4

Am, Bob

Everything I have found so far is in VB.Net and can't find much of c#. So any help would be awesome. Thanks.

Recommended Answers

All 4 Replies

Why don t you use the streamreader class instead and i think at line 5 you want to do this

textBox1.Text = textBox1.Text+line;

but please give some more detalis cause i m not sure what you want exactly

Why don t you use the streamreader class instead

Yea just tried now it is only showing the very last line.

using (StreamReader readFile = new StreamReader("C:/**"))
            {
                string line;
                string[] row;

                while ((line = readFile.ReadLine()) != null)
                {
                        textBox1.Text = line;
                }

            }

you have to concatenate, again

textBox1.Text = textBox1.Text+line;

change line 5 on your first post.

you have to concatenate, again

change line 5 on your first post.

Thanks man, Yea I figured that it was deleting the rows and only showing last one since it's a textbox. Didn't figure to do that though and it worked. Thanks.

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.