TSV / TAB 文件全称为Tab-separated values,即用制表符的方式来存储文件。如何用C#生成tsv文件呢?

生成TSV文件

TextWriter writer = new StreamWriter(@"C:\test.csv");
writer.WriteLine(String.Join("\t", new[] { "abc", "def" }));
writer.WriteLine(String.Join("\t", new[] { "123", "456" }));
writer.Close();

读取TSV文件

using (StreamReader reader = new StreamReader(@"C:\test.csv"))
{
  string line;
  while ((line = reader.ReadLine()) != null)
  {
    string[] a = line.Split(new char[] { (char) 9 });
    Console.WriteLine(a[0]);
  }
}