0
我有三个按钮头/ body/footer.MY头在行尾有1983的空间,然后我的身体开始于1984年当我保存我的身体第一次,而出口到文本文件它复制罚款,但当我点击标题来追加文件一半的数据被替换空间header.how我可以保存我的身体,然后再追加头向下推动身体是可能的。当写入单个文本文件时冲突的文件流
我的头:
FileStream fs = new FileStream(@"C:\Users\IT-Administrator\Desktop\ee.txt", FileMode.Open, FileAccess.ReadWrite);
fs.Seek(0, SeekOrigin.Begin);
StreamWriter sw = new StreamWriter(fs);
//sw.WriteLine(comboBox7.Text +comboBox2.Text +textBox6.Text);
sw.WriteLine("{0}{1}{2}{3,-1983}", comboBox7.Text, comboBox2.Text,textBox6.Text, ' ');
sw.Close();
fs.Close();
我的身体按钮:
if (myDataset == null)
{
return;
}
if (myDataset.Tables[0].Rows.Count == 0)
{
return;
}
DataView vwExport = new DataView(myDataset.Tables[0]);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "TXT file|*.txt";
sfd.FileName = "ticket_info " + ".txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
if (sfd.FileName != "")
{
ExportDatatviewToCsv(sfd.FileName, vwExport);
MessageBox.Show("File has been saved as: " + Environment.NewLine + sfd.FileName + Environment.NewLine + Environment.NewLine + "NB: This dataset has been ordered by t_reference in ascending order. If being combined with an existing dataset - that dataset will also need to be sorted in this way.", "Operation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
如果我理解你。您想要将文本保存到文件中。通过在文件初始化的时候保存body,因为它还没有任何内容,并且你保存了头文件,你希望头文件在body之前被附加到头部?这就是你需要的一切? –