繁体   English   中英

在C#中读取pdf文件时出现System.byte错误

[英]System.byte error while reading a pdf file in C#

我尝试了网站上给出的所有可能的解决方案。

private byte[] GetBinaryFile()
{
    Stream fs = FileUpload1.PostedFile.InputStream;
    BinaryReader br = new BinaryReader(fs);
    Byte[] bytes = br.ReadBytes((Int32)fs.Length);
    return bytes;
}

这是我试图从fileuploader中读取的内容,但是没有用。 然后我改变了主意,首先将文件上传到服务器上,然后尝试读取,但这又给了我相同的system.byte()错误。 问题是它不返回pdf的字节格式,但在我的本地系统上运行良好,是否与服务器有关? 任何帮助将不胜感激

您可以尝试以下方法:

byte[] bytes = new byte[FileUpload1.PostedFile.ContentLength];
bytes = FileUpload1.FileBytes;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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