基本信息
源码名称:两个函数轻松实现txt文本读写
源码大小:0.01M
文件格式:.doc
开发语言:C#
更新时间:2021-08-26
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍


public static string Read_config_txt()
        {
            string config_txt_content = "";
            string exe_path = Application.ExecutablePath;
            int startIndex = exe_path.IndexOf("Debug"); 
            string temp_filebox_path = exe_path.Substring(0, startIndex);
            StreamReader sr = new StreamReader((temp_filebox_path "config.txt"), Encoding.UTF8); 
            string a_line_content = "";
            while ((a_line_content = sr.ReadLine()) != null)
            {
                config_txt_content = config_txt_content a_line_content;
                config_txt_content = config_txt_content.Replace("\t", "");
                config_txt_content = config_txt_content.Replace("\r\n", "");
                config_txt_content = config_txt_content.Replace(" ","");
            }
            sr.Close();
            return config_txt_content;
        }

        public static void Write_config_txt(string config_txt_content)
        {
            string exe_path = Application.ExecutablePath;
            int startIndex = exe_path.IndexOf("Debug"); 
            string temp_filebox_path = exe_path.Substring(0, startIndex);
            StreamWriter sw = File.CreateText(temp_filebox_path "config.txt"); //追加写入
            sw.Write(config_txt_content);
            sw.Flush();
            sw.Close();
        }