.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Converting ReportDocument object into byte array ?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi All,

          Is it possible to convert the Report Document object as a byte array and store it in SQL , later retrieve and assing it to a report ?


View Complete Post

More Related Resource Links

Converting a System.Windows.Control.Image object to byte array.

Hi i need to convert a specific System.Windows.Control.Image object into an (int) array, because i'm trying to convert a silverlight application into a wpf project. private void createGi02GradBrush()<br/> {<br/> WriteableBitmap oWriteableBitmap = new WriteableBitmap(256, 256);<br/> Image oImage = new Image();<br/> oImage.Arrange(new Rect(0, 0, 256, 256));<br/> oImage.Measure(new Size(256, 256));<br/> oImage.Source = new WriteableBitmap(256, 256);<br/> Gi02GradShaderEffect oGi02GradShaderEffect = new Gi02GradShaderEffect();<br/> oGi02GradShaderEffect.pArray = oPImageBrush;<br/> oGi02GradShaderEffect.gi1GradArray = oGi1GradImageBrush;<br/> oImage.Effect = oGi02GradShaderEffect;<br/> oWriteableBitmap.Render(oImage, null);//here<br/> oWriteableBitmap.Invalidate(); <br/> this.oGi02GradImageBrush = new ImageBrush();<br/> this.oGi02GradImageBrush.ImageSource = oWriteableBitmap;<br/> } I've found some similar topics however Image object is not the same and most of its methods aren't available. Here I'm rendering a writablebitmap with a given Image object, but in wpf we need an array. oWriteableBitmap.Render(oImage, null); Any idea? Thanks. Joseph.  

Converting an Image/BitmapImage object into Byte Array and vice versa

Hi,  I have an requirement of developing an application (WPF) that recevies image object from WCF service.

my approch is to convert the image object into stream of bytes (Byte array) in WCF part and then send to  client application. Then client application converts the byte array back to image object.

I am not able to find right sample for my approach.

would you give me guidance and would be gr8 if you provide some samples.


Converting a byte array to a gif


Hi there,

I am currently in the process of trying to convert a byte array into a gif format. So far I have done this:

                        byte[] gif = Convert.FromBase64String(myByteArray);
                        MemoryStream ms = new MemoryStream(gif);
                        Bitmap image = new Bitmap(ms);
                        string pathToSave = Server.MapPath("~/_temp/");
                        iconUrl = string.Format("{0}/{1}.gif", pathToSave, fileName);

When this code block executes, I get the following error:

A generic error occurred in GDI+.

I have made sure that I have the correct permissions for the _temp folder, but I am not sure if I am trying to convert "bad bytes". Could someone perhaps shed some light on this error? 

Converting byte[] array to Int32


Hi guys,

I am trying to read in a binary file created by a legacy VBA application.

One of the sections of the file is a date, which was written out as a four byte segment equivalent a VBA long with value 40451.

In the binary array this is represented as: 33, 67, 101, 135

If I convert the binary array back into a long in VBA I get the number 40451 again.

However, if I create a four byte array in C# and try and convert that to an Int32 using BitConverter I get the value -2023406815.

I have tried reversing the byte order but not getting anything close to 40451.

Anyone got any ideas on how to get the same value as the original VBA long?



Converting a binary file to byte array


Hi Everyone-

I'm retrieving a binary file from the database, a .pdf file that I would like to let the user open and view.  From what I can tell, there are two steps to do this: 

1. Convert binary file to byte array  

2. Convert byte array to file content 

Here's what I've got so far:

 Dim c1 = (From c In dc.Documents _
                     Where c.userID = userGuid _
                     Select New With {c.downloadName, _
                                     c.docData, _
                                     c.type, _

             Dim bArray As Byte() = CType(c1.docData("binary"), Byte())
            If bArray.Length > 0 Then
                Dim fs As System.IO.FileStream = New System.IO.FileStream("d:\xx.pdf", IO.FileMode.Create)
                fs.Write(bArray, 0, bArray.Length)
            End If

This isn't working and I'm having a heck of a time trying to find a solution.  I'm getting a blue squiggly under c1.docData in the Dim bArray line. 

What am I doing wrong?

Cannot convert type 'object[]' to 'byte[]'


I am doing this .. and i want to convert object array to byte array. How should I do that?

Object[] myVal = um.myData;

Byte[] byteArray = (Byte[])myVal;

Conversion of Byte Array to Memory stream


how to convert byte array to memory stream in vb.net.

How to: Serialize Hashtable contained inside another object that is serialized as an array of object

Update:  I've added the entire program in a single block of C# text near the end of these posts that can be placed into a C# Program.cs file of a console project.   I have a class called MyHashtable that inherits from Hashtable and implements IXmlSerializable.  MyHashtable is contained inside another object called MyObject and I need to xml serialize an array of MyObject[].  Whenever I xml deserialize, the hashtable is deserialized, but only 1 of MyObjects from the MyObject[] array is deserialized.  The ReadXml uses "while (reader.NodeType != XmlNodeType.EndElement)" so I don't think the reader is consuming all of the xml internally.   Does anyone know why this is happening?  Thanks.    

How to Pass higher Length of Byte Array to the remoting method

Dear all,I am using a windows application and the businness logic is present in the remote server.Once particular method takes bytearray as input parameter...Whenever the method call is made the function returns value .This is limited for the particular bytearray length. (4109228 bytes).If the length of bytearray crosses 4109228 bytes.I am getting an error that "input stream is not valid binary format".How to Pass higher Length of Byte Array to the remoting method... Greater than 4 MB?I believe something is missing in web.config or app.config...?What could be the issue...? Any sugesstions are welcome....ThanksRavikumar

How to create an extremely large array/object (> 2 GB) without using jagged arrays ?

Hello,I had implemented a matrix scaling algorithm in Java (64-bit) for a university project and have now implemented the code in C# with .NET 3.5 64-bit. One of the operations I did in Java was creating a rectangular array with double[][] = ... (in C# this is a jagged array!) to store a symmetric matrix which is used as input for the algorithm. Since I was using matrices with n up to 30720, memory usage for the single matrix object was around 8 GB in it's maximum and with matrix multiplication around 20 GB.So... now I implemented this in C# and I am shocked to see that double[,] (rectangular arrays) can only be 2 GB in size even on 64-bit! That means that for matrices with n larger than ~15000 I will get OutOfMemory Exceptions although there is a huge amount of free memory (I have two quad core systems with 12 GB and 24 GB Ram). When I use jagged arrays in C# (i.e. double[][]) I can create larger matrices. That is because I have one small array with the size of the row number (i.e. n) and then for each row an array of size n, but they are all single objects so I don't reach the 2 GB per object limit. The problem with jagged arrays is that they are horribly slow for matrice calculations compared to rectangular arrays and even slower compared to single dimension arrays.Actually I intended to rewrite my code and simulate the matrices in single arrays (see sample code below) bec

how to split byte array

hi all,how to split byte array?for eg when i convert byte array to string it will come like as followsbytetostring="%%90,53453%%20,%%20,434234my requirement is i need to split bytearray using the string byte "%%"and need to find out hex value of each linebyte to hex i did like as followsDim strTemp1 As New StringBuilder(Bytes.Length * 2)                                    For intIndex1 = offset To offset + count - 1  'offset is 0 and count is length of the string                                        strTemp1.AppendFormat("{0:x2}", Bytes(intIndex1))                                    Nextthis function resulting the hex value of full string.I need hex value of each byte splitted with "%%"

Converting a Javascript/SQL array for use in asp.net VB

Hi all:   Thank you all in advance for your patience with me on this one!  This will be my first attempt at understanding code-behind. I have a JavaScript banner marquee that I am currently using in an ASP classic site.  I feed the script with banner info from a SQL array and the script runs the banners in a loop.  I want to use this on my ASP.net site conversion (from ASP classic) but I don't even know how to begin.  I have read some books, did the tutorials, but I will still need some help getting off the ground on this. Here is the ASP code.  I don;t care about the tables, rows, etc as that will be converted to CSS.  I just really need to know how to handle the array to feed the script.  Also, I am working in VB.net. I did not include the actual Javasrcipt either...  <% Set RS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT xlaABMiBannersZones.bannerID, bannerfile, link FROM (xlaABMbanners INNER JOIN xlaABMiBannersZones ON xlaABMbanners.bannerid = xlaABMiBannersZones.bannerid) WHERE zoneid = '18' AND enddate >= GetDate()-1 ORDER BY enddate" set RS = conn.execute(SQL) Dim arrMini If RS.BOF AND RS.EOF Then RS.close set RS = nothing Else arrMini = RS.GetRows() End If RS.close set RS = nothing %> <div id="marqueecontainer" onmouseover="copyspeed=pausespe

how to query return all data in Array Object ,Collection Object

how to query return all data in Array Object ,Hash Table ,And DataTable dataRowSelect * From Doc a

write Data to Byte[ ] array

Hi All.i hava a data in string variable for example :string Data = "0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/"and i want to convert this data to binary format so that i can insert this data to Image data field in Database .. can u please give me the solution.Thanks in advance

converting a rdr object to a string


I inherited some code and I need to change a line so that instead of testing to see if the value in a table column is not null, it also tests to see if the value is not empty.

The existing line is:

if (rdr["InnLinkURL"] != null)

"InnLinkURL" is the name of the column being tested.

I thought a solution could be something like:

if (String.IsNullOrEmpty(InnLinkURL) == true)

Not sure how to convert the object to a string, though.

public static string ToString(
 object value

If someone could show me the proper syntax I'd be grateful.

As an alternative, I tried this also but it doesn't seem to work (no errors, just doesn't return true)

if ((rdr["InnLinkURL"] != null) && (rdr["InnLinkURL"] != ""));

>>Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.



I am trying to upload a picture into database using FormView insertItemTemplate. 

FormView is bounded by objectdatasource.

To upload, I placed FileUpload control inside insertItemTemplate.

In table the dataType is image.


Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.

Any swift reply would be appreciated. Thanks.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend