framefile.cs
来自「结构很好的三层数据访问组件。开放源码。是微软企业库数据访问的替代产品之一。」· CS 代码 · 共 62 行
CS
62 行
namespace FrameCountry.FrameBuild
{
using FrameCountry;
using System;
using System.IO;
public class FrameFile
{
private string ClassAlias = "FL";
private FrameCity frameCity = new FrameCity();
public bool TxtRead(string FilePath, ref string ReadStr, ref string ErrorInfo)
{
string functionAlias = "01";
try
{
if (!File.Exists(FilePath))
{
throw new Exception("文件 " + FilePath + " 不存在!");
}
StreamReader reader = File.OpenText(FilePath);
ReadStr = reader.ReadToEnd();
reader.Close();
}
catch (Exception exception)
{
ErrorInfo = "读取文件 " + FilePath + " 错误!\n\r错误信息如下:\n\r" + exception.Message;
ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, ErrorInfo);
return false;
}
return true;
}
public bool TxtWrite(string FilePath, string WriteStr, ref string ErrorInfo)
{
string functionAlias = "00";
try
{
StreamWriter writer;
if (File.Exists(FilePath))
{
writer = File.AppendText(FilePath);
}
else
{
writer = File.CreateText(FilePath);
}
writer.Write(WriteStr);
writer.Close();
}
catch (Exception exception)
{
ErrorInfo = "写入文件 " + FilePath + " 错误!错误信息如下:\n\r" + exception.Message;
ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, ErrorInfo);
return false;
}
return true;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?