[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
}
}