public bool AppendRecord(string fileName, SoilInfo.Record record)
{
FileStream fs = new FileStream(fileName, FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
if (sw == null)
{
MessageBox.Show("没有找到文件,或文件正在被占用", "错误");
return false;
}
record.ProjectName += ",";
record.SoilModelName += ",";
record.Wet += ",";
record.SoilDensity += ",";
record.recordDescription += ",";
record.language += "\r\n";
string str = record.ProjectName + record.SoilModelName + record.Wet + record.SoilDensity + record.recordDescription + record.language;
try
{
sw.WriteLine(str);
}
finally
{
sw.Dispose();
}
sw.Close();
fs.Close();
return true;
}
代码如上所示