Files
U8-Import/NX.ERP.U8/FileHelp.cs

46 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-01-12 14:45:59 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NX.ERP.U8
{
public class FileHelp
{
public static string ReadFile(string strFileName)
{
if (!File.Exists(strFileName))
{
return string.Empty;
}
using (StreamReader streamReader = new StreamReader(strFileName, Encoding.Default))
{
return streamReader.ReadToEnd();
}
}
public static bool WriteFile(string strContentToFile, string strFilePathName, Encoding encoding)
{
using (StreamWriter streamWriter = new StreamWriter(strFilePathName, append: false, encoding))
{
streamWriter.Write(strContentToFile);
return true;
}
}
public static bool WriteFile(string strContentToFile, string strFilePathName)
{
using (StreamWriter streamWriter = new StreamWriter(strFilePathName, append: false, Encoding.Default))
{
streamWriter.Write(strContentToFile);
return true;
}
}
}
}