C#文件类型

时间:2014-03-20 07:18:13

标签: c# file

除了.txt之外,我还可以使用C#插入数据吗?

string file = GenerarPath(Environment.SpecialFolder.MyDocuments, "Pascal Triangle.txt");
var tw = new StreamWriter(file);

Console.WriteLine("\t\t Pascal Triangle in C#");
Console.WriteLine("\t________________________________________");
Console.Write("\nNumber of Rows: ");
int number = int.Parse(Console.ReadLine());
int x = number * 2;
for (int i = 0; i <= number; ++i, x -= 2)
{
    for (int s = 0; s <= x; ++s)
         tw.Write(" ");
    for (int k = 0; k <= i; ++k)
         //Console.Write(String.Format("{0,4:D}", formula(i, k)));
    tw.Write(String.Format("{0,4:D}",pascal(i,k)));//formula(i, k)));
    tw.WriteLine();
}
tw.Close();
Console.WriteLine("Finished");
Console.ReadKey();

谢谢

1 个答案:

答案 0 :(得分:2)

几乎在任何地方。像数据库(Sqlserver,访问),word文件,txt文件一样。