zoukankan      html  css  js  c++  java
  • C#中如何读写文件,控制台

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;

    namespace ConsoleApplication1
    {
        class Program
        {
            public static void Main()
            {
                string[] s = { "c:\\", "d:\\", "e:\\", "f:\\" };
                using (StreamWriter sw = new StreamWriter("1.ini", false))
                //false为直接覆盖该文件,true就直接添加在文件末尾
                {
                    foreach (string t in s)
                    {
                        sw.WriteLine(t);
                    }
                }
                using (StreamReader sr = new StreamReader("1.ini"))
                {
                    String temp = "";
                    string ss = sr.ReadLine();
                    while (ss != null)
                    {
                        temp += ss;
                        Console.WriteLine(temp);
                        ss = sr.ReadLine();
                    }
                }
                Console.ReadLine();
            }
        }
    }

  • 相关阅读:
    记一次unity3d游戏的misc
    【靶场练习_upload-labs复现】Pass01-020
    bugku | login2(SKCTF) 200
    bugku | sql注入2
    buuctf | [强网杯 2019]随便注
    Linux 中 cp 命令(文件复制)
    linux之cp/scp命令+scp命令详解
    StatsD 的使用小结
    深入 webpack 打包机制
    利用webpack打包自己的第一个Vue组件库
  • 原文地址:https://www.cnblogs.com/lixiaolun/p/2831373.html
Copyright © 2011-2022 走看看