/// <summary>
/// 读取TXT文件中的文本
/// </summary>
/// <param name="strPath">TXT文件路径</param>
/// <returns>TXT文件中的文本</returns>
public static string GetFileString(string strPath)
{
string strText = "";
try
{
strText = File.ReadAllText(strPath);
}
catch (Exception ex)
{
TXTHelper.Logs(ex.ToString());
}
return strText;
}
/// <summary>
/// 读取TXT文件中的文本(按照每行存到string[]中)
/// </summary>
/// <param name="strPath">TXT文件路径</param>
/// <returns>TXT文件中的文本(string[])</returns>
public static string[] GetFileArray(string strPath)
{
string[] strText = null;
try
{
strText = File.ReadAllLines(strPath);
}
catch (Exception ex)
{
TXTHelper.Logs(ex.ToString());
}
return strText;
}
/// <summary>
/// 读取TXT文件中的文本(按照每行存到listString中)
/// </summary>
/// <param name="strPath">TXT文件路径</param>
/// <returns>TXT文件中的文本(listString)</returns>
public static List<string> GetFileList(string strPath)
{
List<string> listText = new List<string>();
try
{
string[] strText = File.ReadAllLines(strPath);
foreach (string strLine in strText)
{
listText.Add(strLine);
}
}
catch (Exception ex)
{
TXTHelper.Logs(ex.ToString());
}
return listText;
}