zoukankan      html  css  js  c++  java
  • c#文件操作

    demo1:

            /// <summary>
            /// 将字符串写入到txt文件
            /// </summary>
            /// <param name="filepath"></param>
            /// <param name="contentStr"></param>
            public void WriteTxt(string filepath,string contentStr) {
                if (!File.Exists(filepath))
                {
                    logger.Info("文件不存在");
                    File.CreateText(filepath);
                }
    
                using (StreamWriter sw = new StreamWriter(filepath))
                {
                    sw.WriteLine(contentStr);
                }
            }
    
    
            public string ReadTxt(string filepath)
            {
                StringBuilder sb = new StringBuilder(1024);
                string line;
                using (StreamReader sr = new StreamReader(filepath))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        sb.AppendLine(line);
                    }
                }
                return sb.ToString();
            }

  • 相关阅读:
    不透明度
    浮动塌陷
    滑动门技术
    文本替换
    清除浮动
    浮动
    定位概述
    IE6中使用通用选择器模拟子选择器效果
    js对象
    bzoj:2049: [Sdoi2008]Cave 洞穴勘测
  • 原文地址:https://www.cnblogs.com/softidea/p/3200049.html
Copyright © 2011-2022 走看看