简体   繁体   中英

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

SITUATION

  • Using C# ASP.NET on VS 2008
  • I want to
    • Read a pdf file from my local directory (What stream type do I use? Can I use filestream?)
    • Put this pdf file into a byte[][] variable

QUESTIONS

  • Being new to C#, I would like suggestion (please explain with code), on how I can achieve this.
  • I need to know this to complete my project. Any other inputs will be appreciated.

The code is as follows


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

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

But it is failing, not able to read the file from the d:/test.pdf location. Thanks.

我认为这将为您工作:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM