zoukankan      html  css  js  c++  java
  • C# 操作txt

    读取文件

    FileStream fs = new FileStream("C:\Users\john\Desktop\a.txt", FileMode.Open);
    读取字符
                StreamReader m_streamReader = new StreamReader(fs);
    从0位置开始读
                m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                string arry = "";

    从当前流中读取一行字符
                string strLine = m_streamReader.ReadLine();
                do
                {
                    string[] split = strLine.Split(',');
                    string a = split[3];
                    string b = split[8];
                    if (a.IndexOf("小七孔") == -1)
                    {
                        if (b.IndexOf("2014-04-07") != -1)
                        {
                            arry += "AWSASD" + strLine.Substring(7) + " ";
                        }
                    }
      新的流中读取
                    strLine = m_streamReader.ReadLine();

                } while (strLine != null && strLine != "");
                string ss = arry;
                m_streamReader.Close();
                m_streamReader.Dispose();
                fs.Close();
                fs.Dispose();
                Console.Write(arry);
                Console.ReadLine();

  • 相关阅读:
    ubuntu如何设置Python的版本
    PHP队列之理论篇
    ubuntu系統如何啟動root用戶登陸?
    如何绑定腾讯企业邮箱?
    VMware虚拟机安装Ubuntu并设置root登陆
    毕业生,如何选择高薪资与学习机会?
    如何改变memcached默认的缓存时间?
    PHP常用函数之数组篇
    如何安装并使用bower包依赖工具
    z-score
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/3949905.html
Copyright © 2011-2022 走看看