C#文本文件读写代码

来源:互联网 发布:substr linux 编辑:程序博客网 时间:2024/05/02 05:58

本文原址:http://zhengguomail.blog.163.com/blog/static/23910181200910443933884/

FileInfo version = new FileInfo(LogPath + "yb.txt");
                    FileStream Version_data = version.Open(FileMode.Open);
                    StreamReader Context = new StreamReader(Version_data, System.Text.Encoding.Default);
                    String contents = Context.ReadLine();
                    String contents2 = "";
                    StreamWriter log = new StreamWriter(LogPath + "jk.txt", true);
                    while (contents!=null && contents!="")
                    {
                        contents2 = contents2 + ";" + contents.Substring(contents.IndexOf("= /"") + 3, contents.IndexOf("/";") - contents.IndexOf("= /"") - 3);
                        contents = Context.ReadLine();
                    }
                    log.WriteLine(contents2);
                    log.Close();
                    StreamWriter log2 = new StreamWriter(LogPath + TimeUtil.getDate() + "SMTATTIMEError2.txt", true);

                    log2.WriteLine("time:" + System.DateTime.Now.ToLongTimeString());

                    log2.Close();

原创粉丝点击