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();
            }
        }
    }

  • 相关阅读:
    字符个数统计
    面试题——字符的左右移动
    5. Longest Palindromic Substring
    Linux- AWS之EC2大数据集群定时开关机
    Openldap- 大机群身份验证服务
    Linux- 自动备份MySQL数据库脚本
    Linux- 运维
    JAVA- 切换默认的Java
    HIVE- 新建UDF范例
    Hadoop- 集群启动详解
  • 原文地址:https://www.cnblogs.com/lixiaolun/p/2831373.html
Copyright © 2011-2022 走看看