[csharp]
public static void SaveTxt(string sFileName, string sContent)
{
try
{
if (!System.IO.File.Exists(sFileName))
{
FileStream fs;
fs = File.Create(sFileName);
fs.Close();
}
FileStream fsTxtWrite = new FileStream(sFileName, FileMode.Create, FileAccess.Write);
StreamWriter srWrite = new StreamWriter(fsTxtWrite, System.Text.Encoding.UTF8);
//StreamWriter srWrite = new StreamWriter(fsTxtWrite, System.Text.Encoding.Default);
srWrite.Write(sContent);
srWrite.Close();
srWrite.Dispose();
fsTxtWrite.Dispose();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
#region ### error info
try
{
string sFolder = Directory.GetParent(sFileName).ToString();
string sErrFullName = sFolder + "_err_" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
if (!System.IO.File.Exists(sErrFullName))
{
FileStream fs;
fs = File.Create(sErrFullName);
StreamWriter srWrite = new StreamWriter(fs, System.Text.Encoding.UTF8);
srWrite.Write(sFileName);
srWrite.Close();
srWrite.Dispose();
fs.Close();
}
}
catch (Exception ex2)
{ }
#endregion ###error
}
}