c#文件读入读出笔记

来源:互联网 发布:蛐蛐钢琴软件 编辑:程序博客网 时间:2024/05/17 21:38
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            string[] ss = new string[100];            string[] Str = File.ReadAllLines(@"D:\a.txt", Encoding.Default);            for (int i = 0; i < Str.Length; i++)            {                 ss[i] = Str[i];                ss[i]=ss[i].Replace("  ", " ");                          }            File.WriteAllLines(@"D:\b.txt", ss);            Console.ReadLine();        }          }}

比较简单的程序,实现了按行读入数据,并且替代数据中的两个空格为一个空格。
0 0
原创粉丝点击