using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ciles
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
FileInfo f = new FileInfo(@"c:\ciles.txt");
StreamWriter w = f.CreateText();
int count = 0;
for (count=0; count <= 720; count++)
{
w.Write("{0,4}", count);
w.Write(".000000 "); if (count % 5 == 0)
w.Write("\r\n");
} for (count=721; count<=1720;count++ )
{
w.Write("{0,4}", count);
w.Write(".176700 ");
if (count % 5 == 0)
w.Write("\r\n");
} }
}
}
问题很简单, 就是要写1720个数据,每行写5个,可是最后写出来的只有1651个,
这段代码是非常简单的,但是我看了好几遍实在是看不出有什么问题,搞不懂.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ciles
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
FileInfo f = new FileInfo(@"c:\ciles.txt");
StreamWriter w = f.CreateText();
int count = 0;
for (count=0; count <= 720; count++)
{
w.Write("{0,4}", count);
w.Write(".000000 "); if (count % 5 == 0)
w.Write("\r\n");
} for (count=721; count<=1720;count++ )
{
w.Write("{0,4}", count);
w.Write(".176700 ");
if (count % 5 == 0)
w.Write("\r\n");
} }
}
}
问题很简单, 就是要写1720个数据,每行写5个,可是最后写出来的只有1651个,
这段代码是非常简单的,但是我看了好几遍实在是看不出有什么问题,搞不懂.
但是我想不通,为什么没写w.close()就会这样呢?
既不是全写不出来,也不是全写出来,而只是最后的几个写不出来呢.