C# : How to convert a local pdf file to a byte [][]

标签 c# byte

情况

  • 在 VS 2008 上使用 C# ASP.NET
  • 我想
    • 从我的本地目录读取 pdf 文件(我使用什么流类型?我可以使用文件流吗?)
    • 把这个pdf文件放到一个byte[][]变量中

问题

  • 作为 C# 的新手,我想就如何实现这一目标提出建议(请用代码解释)。
  • 我需要知道这些才能完成我的项目。任何其他输入将不胜感激。

代码如下


   <code>byte[][] pdfDoc= new byte[1][];</code><br/>
   <code>byte[] outputDoc = File.ReadAllBytes(@"d:/test.pdf");</code><p></p>

for (int x = 0; x < pdfDoc.Length; x++)
    {
        pdfDoc[x] = outputDoc;

    }

但它失败了,无法从 d:/test.pdf 位置读取文件。 谢谢。

最佳答案

我认为这对你有用:

byte[] bytes = File.ReadAllBytes("c:\\folder\\myfile.pdf");

关于C# : How to convert a local pdf file to a byte [][],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11231639/

相关文章:

c# - 使用 Visual Studio WPF 编辑器创建不适合 Windows GUI 的 GUI

c# - 如何在没有标识列的SQL Server中查找最后插入的行

java - 替换 byte[] 中的字符串

c++ - 如何在 C++17 中将 std::string 转换为 std::vector<std::byte>?

c# - 为什么没有引发我在 C# 中的自定义事件?

javascript - 单击“搜索”按钮后未收到客户端消息

perl - 如何在 perl 中使用原始字节

python - 使用十进制 ASCII 值转义字符串中的序列?

c# - 从字节数组转换为字符串十六进制 C#

c# - VS 2010 : Prevent display of Build Summary in the output window