static void Main(string[] args)
        {
            //C#文件流写文件,默认追加FileMode.Append
            string msg = "okffffffffffffffff";
            byte[] myByte = System.Text.Encoding.UTF8.GetBytes(msg);
            using (FileStream fsWrite = new FileStream(@"D:\1.txt", FileMode.Append))
            {
                fsWrite.Write(myByte, 0, myByte.Length);
            };
            //c#文件流读文件
            using (FileStream fsRead = new FileStream(@"D:\1.txt", FileMode.Open))
            {
                int fsLen = (int)fsRead.Length;
                byte[] heByte = new byte[fsLen];
                int r = fsRead.Read(heByte, 0, heByte.Length);
                string myStr = System.Text.Encoding.UTF8.GetString(heByte);
                Console.WriteLine(myStr);
                Console.ReadKey();
            }
        }

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-01-24
  • 2021-12-10
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-07-20
  • 2021-07-23
  • 2022-12-23
  • 2021-11-14
相关资源
相似解决方案