Invoke Code activity issue in converting image format

I am trying to convert the image to base64 format using Invoke code activity. But i couldn’t do it
My code is
Static void Main(String args)
{
byte imageArray = System.IO.File.ReadAllBytes(@“C:\Users\DELL\Downloads\captcha (1).png”);
String base64ImageRepresentation = Convert.ToBase64String(imageArray);
}
Please help me to resolve this issue.

Why do you want to use Invoke Code Activity.
You can do with Simple Assign Activities.

create a variable imageArray (datatype: byte) and base64ImageRepresentation (datatype: String)

Assign Activity, imageArray = System.IO.File.ReadAllBytes(PATH_OF_IMAGE)
Assing Activity, base64ImageRepresentation = Convert.ToBase64String(imageArray)

If you get error - please add missing namespaces.

Regards,
Karthik Byggari

4 Likes

No function or procedure can be used inside invoke code activity. Just leave two line body of your main method.

1 Like

It works :+1:
many thanks

create a variable imageArray (datatype: byte) and base64ImageRepresentation (datatype: String)

Hi, what is the exact data type for imageArray ? i can’t find the byte datatype.

Or can you do a sample workflow for converting of image into binary? i need to save the binary or the blob in SQL. Thanks everyone.