Byte[] Read from datatable


I have a data table stored the value of image byte in the format of byte.

I need to read the byte from the data table. Need some help on it.

not all details are clear. Can you check:
myByteArr = DirectCast(dtData.Rows(0)(ColNameOrIndex), byte())

we prototype it forthe datatable first row col value, to check if directcast lut us do the conversion

Am getting the below error while reading this.

Assign: Unable to cast object of type ‘System.String’ to type ‘System.Byte’.

please share with us the implementation part and some sample values. Could it be the case that the data is base64 encoded?

My datatable string looks like this.


can you also share? e.g. a screenshot. Thanks

byte bytesjdh = (byte)dtImage.Tables[0].Rows[0][“Image”];
string result = Convert.ToBase64String(bytesjdh);
string hex = BitConverter.ToString(bytesjdh);
if (!Directory.Exists(imgAbsolutePath))
if (File.Exists(imgAbsolutePath + FileName))
File.Delete(imgAbsolutePath + FileName);
//FileName = txtImageID.Text + “.jpg”;
using (Stream stream = new System.IO.FileStream(imgAbsolutePath + FileName, FileMode.CreateNew))
stream.Write(bytesjdh, 0, bytesjdh.Length);
System.Drawing.Image ImageDetails = System.Drawing.Image.FromStream(stream);
HeightT = ImageDetails.Height.ToString();
WidthT = ImageDetails.Width.ToString();
Size sdf = ImageDetails.Size;

This is the code used to convert this to image in application level. I need to implement the same in uipath.

perfect, we assume an invoke code set to c#, rigth?

Let us clear following e.g. fro immediate panel:

we do feel that there the conversion paths is going to the wrong direction

then we need to decode the base64 string

Ok, your UiPath project is set to VB or C#?

i have used c# only

How to decode this? Can you help

you can play with the immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

so you can start and try the statements


afterwards we can use
File.WriteAllBytes(YourFileFullPath, YourByteArrayVar)
write out to the file system

Am getting the below error.

Dummy.xaml: No compiled code to run
error CS1061: ‘System.Data.DataTable’ does not contain a definition for ‘Tables’ and no extension method ‘Tables’ accepting a first argument of type ‘System.Data.DataTable’ could be found (are you missing a using directive or an assembly reference?) At line 0

Code :

byte bytevd= (byte)dtImage.Tables[0].Rows[0][a];

Language : CSharp

Arguments :

a → String
dtimage → DataTable

kindly note: YourDataTableVar.Rows vs. dtImage.Tables[0].Rows
as mentioned just do the quick prototyping within the immediate panel