C# File.ReadAllBytes() 只读取前 9k 字节

C# File.ReadAllBytes() Only reads first 9k bytes

我一直在尝试逐字节读取文件,以便稍后可以仅从我的单个 .exe 文件创建它。 我试图读取该文件的各个字节并将 em 加载到字节数组中。 但是当我尝试使用这个程序阅读它们时

using System;
using System.IO;

namespace ok
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] buffer = null;
            using (FileStream fs = new FileStream(@"D:\Praca\programowanie\Visual Studio\C#\ok\ok\bin\Debug\net5.0\temp.docx", FileMode.Open, FileAccess.Read))
            {
                buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
            }

            for (int i = 0; i <= 13025; i++)
            {
                Console.WriteLine(buffer[i].ToString() + ",");
            }
        }

    }
}

它执行 return 个单独的字节,但它只 return 前 9000 个字节左右,然后关闭程序。 有人能帮我一下吗? 如果需要,我很乐意提供更多详细信息

抱歉,这是一个愚蠢的问题。 事实证明它读取一切都很好,但是 9000 是 CMD window 的大小限制。 我将只读取前 8500 个字节,然后手动添加它们。