zoukankan      html  css  js  c++  java
  • File类和FileInfo

    一个是静态类(File)一个是只能被实例化才能使用的(FileInf)          

      const string sourcepath = @"li.txt";
                const string destpath = @"lichen1.txt";
                //使用fileinfo构造函数的实例,需要传递一个文件的路径的字符串
                fileinfo ff = new fileinfo(sourcepath);
                //exists 方法在fileinfo也有
                if (!ff.exists)
                {
                    using (streamwriter sw = ff.createtext())
                    {
                        sw.writeline("李晨。txt ");
                        sw.flush();
                    }
                }
                // ff.delete();
                file.delete(destpath);
                ff.copyto(destpath);
                file.delete(destpath);
                ff.moveto(destpath);
                //z追加文件
                using (streamwriter sw1 = ff.appendtext())
                {
                    sw1.writeline("zuij");
                    sw1.flush();

                }
                using (streamreader sr = ff.opentext())
                {
                    console.writeline(sr.readtoend());
                }

  • 相关阅读:
    hadoop面试
    常用脚本
    1.kafka
    2.flink
    java面试
    Hbase 项目
    linux 2>&1 和 &的意思
    Jetbrains系列产品重置试用方法
    解决GitHub网页githubusercontent地址无法访问问题
    stylus 成熟的写法
  • 原文地址:https://www.cnblogs.com/lichen396116416/p/1927056.html
Copyright © 2011-2022 走看看