Hi,
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.
Hi,
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.
0xFFD8FFE000104A46494600010100000100010000FFDB0043000D090A0B0A080D0B0A0B0E0E0D0F13201513121213271C1E17202E2931302E292D2C333A4A3E333646372C2D405741464C4E525352323E5A615A50604A51524FFFDB0043010E0E0E131113261515264F352D354F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4F4FFFC00011080320032003012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D01020300041105122131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435…
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))
{
Directory.CreateDirectory(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;
//stream.Flush();
//stream.Close();
stream.Dispose();
}
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:
YourDataTableVar.Rows[0][“Image”].GetType()
we do feel that there the conversion paths is going to the wrong direction
then we need to decode the base64 string
e.g.
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
YourDataTableVar.Rows[0]["Image"].GetType()
YourDataTableVar.Rows[0]["Image"].ToString()
Convert.FromBase654String(YourDataTableVar.Rows[0]["Image"].ToString())
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