using System.Text; namespace Complex.Application.Common { public class FileIO { //============================================================== public FileIO() { // // TODO: Add constructor logic here // } //============================================================== /// /// ثبت محتوا در یک فایل /// /// نام فایل /// محتوای فایل public static void Write(string fileName, string content, bool activeInServer = false) { //if (!SystemDefine.IsLocal && !activeInServer) // return; //System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("/FileIO/" + fileName), content, Encoding.UTF8); Writeln(fileName, content, activeInServer); } //============================================================== public static void Clear(string fileName) { //return; System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "/FileIO/" + fileName, "", Encoding.UTF8); } //============================================================== /// /// ثبت محتوا در یک فایل در یک خط جدید /// /// نام فایل /// محتوای فایل public static void Writeln(string fileName, string content, bool activeInServer = false) { //try { System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "/FileIO/" + fileName, content + "\r\n", Encoding.UTF8); } //catch { } } //============================================================== /// /// ثبت محتوا در یک فایل در یک خط جدید /// /// نام فایل /// محتوای فایل public static void Writeln(string fileName, string description, Exception exc, bool activeInServer = false) { //if (!SystemDefine.IsLocal && !activeInServer) // return; try { Writeln(fileName, ">>>>>>"); Writeln(fileName, description); while (exc != null) { Writeln(fileName, exc.Message); Writeln(fileName, exc.StackTrace); exc = exc.InnerException; } Writeln(fileName, "<<<<<<"); } catch { } } //============================================================== } }