Problems with Save Image Activity File Name path. Error: Check if the file name is a valid path

Hello, everybody,
while saving a image (obtained by the activities : send hotkey : CTRL+C and Invoke Method GetImage with targhet type: System.Windows.Forms.Clipboard.) I have this error: Save Image: Save image failed. Check if the file name is a valid path.

I tried to use the folder exists activity in the same folder and it returns true,
I have this problem on a Virtual Machine, in my local everithing works.
can you help me please?

@Anna_Totale

Welcome to the community

As per error the path provided in the vm looks invalid…did you try to print the path that you provided and check…

The fullpath including file

Cheers

thank you @Anil_G.
yes I tryed and this is the result: “C:\\Users\\user\\Documents\\UiPath\\FOLDER1\\Data\\SM37\\RowsScreens\\Oct-20_2023_MP_PROCESS_CNS.jpg”

the problem is that I don’t have this error everytime, but only in some runs.

@Anna_Totale

In the vm the user would be different that the user you use normally right

Did you happen to check that

Cheers

What do you have in the Save Image activity for where to save it?

The double slashes are an invalid path.

@postwick thank you for the help!
I have the string with the path write with single slash and concatenate to some string variables : “Data\SM37\RowsScreens"+DateTime.Now.ToString(“MMM-dd_yyyy_”)+CurrentRow(0).ToString+”.jpg"

This will result in Data\SM37\RowsScreensOct-25_2023_MP_PROCESS_CNS.jpg

Notice the missing \ character after RowsScreens. You should always use Path.Combine to build paths:

Path.Combine(“C:\Users",Environment.UserName,“Documents\UiPath\FOLDER1\Data\SM37\RowsScreens”,DateTime.Now.ToString(“MMM-dd_yyyy_”)+CurrentRow(0).ToString+”.jpg”)

It’ll make sure all the \ are correct.

Oh sorry, I noticed now , but in the code is right so the problem persist …

Put a Log Message before the Save Image activity and output the same path you’re providing to the Save Image, so we can see the path. Post a screenshot of the Log Message’s output.

image

I added a folder exists for the folder, and the result is true, then you can see the path

You need to provide the full path, not a partial path.

I also tryed :confused:
image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.