zoukankan      html  css  js  c++  java
  • 文件读写,尝试filestream和streamreader,streamwriter

    将文件11.txt读出来,再写入11_副本.txt里面。

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.IO;
     6 
     7 namespace ConsoleApplication1
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             FileStream aFile = new FileStream(@"C:UsersAdministratorDesktop11.txt",FileMode.OpenOrCreate);
    14             StreamReader aa = new StreamReader(aFile);
    15             FileStream bFile = new FileStream(@"C:UsersAdministratorDesktop11_副本.txt", FileMode.OpenOrCreate);
    16             StreamWriter bb = new StreamWriter(bFile);
    17             string res = aa.ReadLine();
    18            
    19             while (res != null)
    20             {
    21                 bb.WriteLine(res);
    22                 res = aa.ReadLine();
    23             }
    24             aa.Close();
    25             aFile.Close();
    26             bb.Close();
    27             bFile.Close();
    28             
    29         }
    30 
    31     }
    32 }
  • 相关阅读:
    java 8
    内存溢出VS内存泄漏
    dubbo zk 分布式服务项目搭建与配置
    转发 VS 重定向
    过滤器
    Synchronized
    java 泛型
    spring 整合 mongo
    泛型
    反虚拟机
  • 原文地址:https://www.cnblogs.com/wyc199288/p/3664128.html
Copyright © 2011-2022 走看看