⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framefile.cs

📁 结构很好的三层数据访问组件。开放源码。是微软企业库数据访问的替代产品之一。
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -