【问题标题】:Reading any type of file in C#在 C# 中读取任何类型的文件
【发布时间】:2023-04-01 14:00:02
【问题描述】:

我的程序需要从给定的目录路径读取任何类型的文件,并且必须将该信息写入字节数组。

 string combine = Path.Combine(precombine, filename);
 string content = System.IO.File.ReadAllText(combine);

这样我可以读取文本文件,但是我必须读取所有类型的文件,例如音乐或图像,并将它们写入字节数组。

【问题讨论】:

    标签: c# file directory filestream


    【解决方案1】:

    使用File.ReadAllBytes 方法

    byte[] fileContent = System.IO.File.ReadAllBytes(combine);
    

    【讨论】:

      猜你喜欢
      • 2013-12-03
      • 2010-11-24
      • 2021-07-18
      • 2017-10-02
      • 2011-05-05
      • 1970-01-01
      • 2018-11-07
      • 2018-02-26
      • 1970-01-01
      相关资源
      最近更新 更多