zoukankan      html  css  js  c++  java
  • 关于写文件流的情况

    最初写信息到ini文件中

    File.Create(uIniPath);

    StreamWriter sw = new StreamWriter(uIniPath);

    sw.WriteLine("");

    sw.Flush();

    sw.Close();

    以上代码,偶尔会出现进程被使用,无法调用的问题,于是用下面这种

    using(FileStream fs = File.Create(uIniPath))

    {

      byte[] info = new UTF8Encoding(true).GetBytes("");

      fs.Write(info,0,info.Length);

    }

    这样写避免了进程访问的问题,但是似乎内容换行不方便,于是又找了下面这种写法

    using(FileStream fs = File.Create(uIniPath))

    {

      StreamWriter sw = new StreamWriter(fs);

      sw.WriteLine("");

      sw.Close();

    }

    至此,满足现有要求。

    如有啥问题,欢迎交流

  • 相关阅读:
    植物园偶遇一直喵
    植物园偶遇一直喵
    美食篇
    美食篇
    端午节路过南站
    端午节路过南站
    黄山云海
    黄山云海
    Android (1)
    树和树算法(1)
  • 原文地址:https://www.cnblogs.com/loushuibazi/p/3992363.html
Copyright © 2011-2022 走看看