NetQuickJamesFrame/Util/File_TXTHelper.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NetQuickJamesFrame.Util
{
public class File_TXTHelper
{
//open file with SteamReader
public static string readTXT(string filePath)
{
StringBuilder sb = new StringBuilder();
FileStream fileStream = new FileStream(filePath, FileMode.Open);
StreamReader sr = new StreamReader(fileStream);
try
{
string line;
while ((line = sr.ReadLine()) != null)
{
sb.Append(line.ToString());
}
sr.Close();
}
catch (IOException ex)
{
sr.Close();
throw new Exception(ex.Message);
}
return sb.ToString();
}
//Write file with steamwrite
public static void WriteTXT(string filePath, string str)
{
FileStream fs = new FileStream(filePath, FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
try
{
sw.WriteLine(str);
sw.Flush();
sw.Close();
fs.Close();
}
catch (IOException ex)
{
sw.Flush();
sw.Close();
fs.Close();
throw new Exception(ex.Message);
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
