Error while saving a screenshot

Hi

When a exception occurs my code takes a screenshot and saves the image in a given folder in “png format” but sometimes a receive the below mentioned error:

UiPath.Core.ImageOperationException: Save image failed. Check if the file name is a valid path —> System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at UiPath.Core.Image.SaveFile(String fileName)
— End of inner exception stack trace —
at UiPath.Core.Activities.InvokeWorkflowFile.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Hey man,

any luck with this error?

If you are sure image has been captured and you suspect issue with the activity, try using invoke method and see if works.

image

image

If you think Uipath.Core.Image(say Image1) is the culprit , create a variable System.Drawing.Image (say Image2)

assign Image2=Image1

and try saving (first with activity, if not, then invoke)

image