C#for循环逐行写入(C# for loop to write line by line)
我试图写一行文本75次,并将数字增加1,直到达到75的条件。 从2开始是有原因的。 这是代码
class WriteTextFile
{
static void Main()
{
string path = "C:\\Users\\Writefile\\test.txt";
string line;
int i = 2;
while (i <= 75 )
{
line = "Error_Flag = 'FOR_IMPORT' and location_type = 'Home' and batch_num = " + i + "\n";
System.IO.File.WriteAllText(@path, line);
i++;
}
}
}
有了这个,它最后只写了一行75。 我希望它用相同的东西写出所有74行,每次只有这个数字上升。 谢谢。
I am trying to write one line of text 75 times and increase the number by 1 till it hits the 75 condition. Starting at 2 for a reason. Here's the code
class WriteTextFile
{
static void Main()
{
string path = "C:\\Users\\Writefile\\test.txt";
string line;
int i = 2;
while (i <= 75 )
{
line = "Error_Flag = 'FOR_IMPORT' and location_type = 'Home' and batch_num = " + i + "\n&#