in

How to import a text file to datagridview?


i’m struggling with something that I habitually do good but I don’t understand why this time it don’t work. I try to take a .txt file and import it into a datagridview.

This is the code i’m using. The logic is there. I tried to read almost all posts about it and the same logic is applied here but it just don’t want to work:

string[] lines = File.ReadAllLines(@"myPath");
            string[] values;


            for (int i = 0; i < lines.Length; i++)
            {
                values = lines[i].ToString().Split(':');
                string[] row = new string[values.Length];

                for (int j = 0; j < values.Length; j++)
                {
                    row[j] = values[j].Trim();
                }
                dgvProxy.Rows.Add(row);
            }

I have a a .txt file and the data inside look like this:
1.1.1.1:8080
1.3.4.5:80
etc.

It’s IP:PORT.

And the result look like this:
enter image description here

Thank you.



Source: https://stackoverflow.com/questions/70553290/how-to-import-a-text-file-to-datagridview

A pure Go game engine

A Marvel Platform challenge Using React