9日站立会议

今天大家都编写了一些代码,我编写了自己的消费情况转入到文本中

private void button3_Click(object sender, EventArgs e)
{
string s = dateTimePicker1.Text;
DirectoryInfo d = Directory.CreateDirectory(Test.path + @"\文本数据\" + s.Substring(0,8));
string p = d.FullName;
using (FileStream fs = new FileStream(p + @"\" + s.Substring(8) + @".txt", FileMode.OpenOrCreate, FileAccess.Write))
{

string listStr = null;
for (int i = 0; i < listBox1.Items.Count; i++)
{
listStr += listBox1.Items[i] + "\r\n";
}
byte[] buffer = Encoding.Default.GetBytes(listStr);
fs.Write(buffer, 0, buffer.Length);
if (File.Exists(p + @"\" + s.Substring(8) + @".txt"))
{
MessageBox.Show("文件写入成功!!!");
}
else
{
MessageBox.Show("文件写入失败!!!");
}
}
}

private void Form新建账目_Load(object sender, EventArgs e)
{

}

private void Form新建账目_FormClosed(object sender, FormClosedEventArgs e)
{
if (flag)
{
return;
}
else
{
Test._f.Close();
}
}
}
}

 

posted @ 2018-12-09 21:19  瘦子肉嘟嘟  阅读(81)  评论(0编辑  收藏  举报