Tab and space separated by

Tab and space separated by

k005
Advisor Advisor
301 Views
1 Reply
Message 1 of 2

Tab and space separated by

k005
Advisor
Advisor

Hi all,

 

 

I need to fix this code as follows.

 

Let both space and tab key be processed in the delimited file.

 

can i fix this?

 

Thanks in advance for the help friend.

 

 

            string[] lines = File.ReadAllLines(filePath);
            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();
                }
                dataGridView1.Rows.Add(row);
            }

 

 

0 Likes
Accepted solutions (1)
302 Views
1 Reply
Reply (1)
Message 2 of 2

k005
Advisor
Advisor
Accepted solution

 

 

values = lines[i].ToString().Split('\t',' ')

 

 

 

**** issue has been resolved. ******

0 Likes