这样写对吗
try
{
string SHcontractTxt = @"H" + System.DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
FileStream fs = new FileStream(@"\10.101.0.10\erpsap\0100\" + SHcontractTxt + CreateRandomNo1().ToString(), FileMode.CreateNew, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
sw.Flush();
sw.BaseStream.Seek(0, SeekOrigin.End);
for (int i = 0; i < dsContract.Tables[0].Columns.Count; i++)
{
string a = dsContract.Tables[0].Rows[0][i].ToString();
sw.Write(a.Trim() + "|");
}
sw.WriteLine();
sw.Flush();
sw.Close();
return true;
}
catch (Exception ex)
{
return false;
}