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之前被附加到頭部?這就是你需要的一切? –