I am reading the pdf correctly but for some reason it keeps thinking that my Byte is an Integer and keeps throwing an InvalidCastException Error
Here is the code snippet:
Expand|Select|Wrap|Line Numbers
- Const ChunkSize As Integer = 1024
- Dim buffer() As Byte = New Byte(ChunkSize) {}
- Dim binary(reader("document")) As Byte *** Exception is thrown here***
- Dim ms As New MemoryStream(binary)
- Dim SizeToWrite As Integer = ChunkSize
Expand|Select|Wrap|Line Numbers
- Server Error in '/' Application.
- Conversion from type 'Byte()' to type 'Integer' is not valid.
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
- Exception Details: System.InvalidCastException: Conversion from type 'Byte()' to type 'Integer' is not valid.
- Source Error:
- Line 40: Const ChunkSize As Integer = 1024
- Line 41: Dim buffer() As Byte = New Byte(ChunkSize) {}
- Line 42: Dim binary(reader("document")) As Byte
- Line 43: Dim ms As New MemoryStream(binary)
- Line 44: Dim SizeToWrite As Integer = ChunkSize
Expand|Select|Wrap|Line Numbers
- [InvalidCastException: Conversion from type 'Byte()' to type 'Integer' is not valid.]
- Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value) +987
- HardCopyOrderForm.Download.btnPDF_Click(Object sender, EventArgs e) in *************************************************************************************************************** System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
- System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
- System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
- System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
- System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
- System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563