first commit
This commit is contained in:
81
Complex.Application/Other/Common/FileIO.cs
Normal file
81
Complex.Application/Other/Common/FileIO.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Complex.Application.Common
|
||||
{
|
||||
public class FileIO
|
||||
{
|
||||
//==============================================================
|
||||
|
||||
public FileIO()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
//==============================================================
|
||||
|
||||
/// <summary>
|
||||
/// ثبت محتوا در یک فایل
|
||||
/// </summary>
|
||||
/// <param name="fileName">نام فایل</param>
|
||||
/// <param name="content">محتوای فایل</param>
|
||||
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);
|
||||
}
|
||||
//==============================================================
|
||||
|
||||
/// <summary>
|
||||
/// ثبت محتوا در یک فایل در یک خط جدید
|
||||
/// </summary>
|
||||
/// <param name="fileName">نام فایل</param>
|
||||
/// <param name="content">محتوای فایل</param>
|
||||
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 { }
|
||||
}
|
||||
//==============================================================
|
||||
|
||||
/// <summary>
|
||||
/// ثبت محتوا در یک فایل در یک خط جدید
|
||||
/// </summary>
|
||||
/// <param name="fileName">نام فایل</param>
|
||||
/// <param name="content">محتوای فایل</param>
|
||||
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 { }
|
||||
}
|
||||
//==============================================================
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user