您可以使用System.IO命名空间中的File.WriteAllBytes方法将byte数组写入文件。示例如下:
using System; using System.IO; class Program { static void Main() { byte[] byteArray = { 0x48, 0x65, 0x6C, 0x6C, 0x6F }; // Hello File.WriteAllBytes("test.txt", byteArray); Console.WriteLine("Byte array has been written to file."); } } 在上述示例中,我们创建了一个byte数组byteArray,其中包含ASCII编码的字符串"Hello"。然后使用File.WriteAllBytes方法将这个byte数组写入了名为test.txt的文件中。最后输出一条消息表明byte数组已被成功写入文件。