zoukankan      html  css  js  c++  java
  • c#文本文件写入

      string err = "Hellod world";
                FileStream fs = null;
                string filePath = HttpContext.Current.Server.MapPath("~/Error.txt");
                if (!File.Exists(filePath))
                {
                    using (fs = File.Create(filePath)){ }
                }
                //将待写的入数据从字符串转换为字节数组
                Encoding encoder = Encoding.UTF8;
                byte[] bytes = encoder.GetBytes(err);
                fs = File.OpenWrite(filePath);
                //设定书写的开始位置为文件的末尾
                fs.Position = fs.Length;
                //将待写入内容追加到文件末尾
                fs.Write(bytes, 0, bytes.Length);
                fs.Dispose();
                fs.Close();
  • 相关阅读:
    ffmpeg
    HDU 1031 Design T-Shirt
    HDU 1029 Ignatius and the Princess IV
    HDU 1022 Train Problem I
    HDU 1017 A Mathematical Curiosity
    HDU 1015 Safecracker
    HDU 1002 A + B Problem II
    HDU 1070 Milk
    高精度算法(一)
    codeblocks 使用心得
  • 原文地址:https://www.cnblogs.com/ft-Pavilion/p/5413715.html
Copyright © 2011-2022 走看看