zoukankan      html  css  js  c++  java
  • 读写文件流

     1        string path = @"c:\temp\MyTest.txt";
     2        try 
     3        {
     4            if (File.Exists(path)) 
     5            {
     6                File.Delete(path);
     7            }

     8
     9            using (StreamWriter sw = new StreamWriter(path)) 
    10            {
    11                sw.WriteLine("This");
    12                sw.WriteLine("is some text");
    13                sw.WriteLine("to test");
    14                sw.WriteLine("Reading");
    15            }

    16
    17            using (StreamReader sr = new StreamReader(path)) 
    18            {
    19                while (sr.Peek() >= 0
    20                {
    21                    Console.WriteLine(sr.ReadLine());
    22                }

    23            }

    24        }
     
    25        catch (Exception e) 
    26        {
    27            Console.WriteLine("The process failed: {0}", e.ToString());
    28        }

    29
  • 相关阅读:
    GX转账站点无法访问的问题

    .NET易忘备留 ORACLE存储过程调用
    Oracle 字符串函数
    Oracle 数值函数
    AJAX.JSONP 跨域
    机器人部署的注意事项
    IE6、7绝对定位层被遮挡的原因(主要是父层决定的)
    Oracle 新手问答
    字符设备驱动范例
  • 原文地址:https://www.cnblogs.com/tiasys/p/605234.html
Copyright © 2011-2022 走看看