C # Odczytaj plik tekstowy zawierający dane rozdzielone tabulatorami
Mam jakiś kod:
<code> public static void ReadTextFile() { string line; // Read the file and display it line by line. using (StreamReader file = new StreamReader(@"C:\Documents and Settings\Administrator\Desktop\snpprivatesellerlist.txt")) { while ((line = file.ReadLine()) != null) { char[] delimiters = new char[] { '\t' }; string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { Console.WriteLine(parts[i]); sepList.Add(parts[i]); } } file.Close(); } // Suspend the screen. Console.ReadLine(); } </code>
Czyta w pliku tekstowym, który zawiera dane rozdzielone tabulatorami i dzieli dane na osobne słowa.
Mam problem z tym, że gdy dane zostaną rozdzielone, nadal mają ogromne ilości białej przestrzeni po lewej i prawej stronie na losowych ciągach na liście (w rzeczywistości większość z nich to robi). Nie mogę przyciąć napisu, ponieważ usuwa on tylko białe znaki, a technicznie nie jest to białe pole.
Każdy ma jakieś pomysły, jak obejść ten problem !?