How to open all the images in a folder

Hello. I am doing an automation where I have to open all the images that are in a folder, I am using Directory.GetFiles(sourcePath, “.”, SearchOption.AllDirectories) to get all the images, but when I try to open the images it only opens the first one and throws the following exception. I don’t know how it could be solved.

Hello @camilacalderon

Can you plz check the value of the file which you are trying to open.

Also can you share the screenshot of the workflow which you have created.


This is the workflow

  1. I get all the files found in the folders (in this case images) and store it in an array of strings called “allSubFoldersFile”


  1. Iterate over all the files (images) store in the allSubFoldersFile variable


  1. Open the images one by one with the start process activity


Note: all the images have a size.

Additional note: point 3 is where the exception shown above is generated.

For the Start Process activity, you enter the path to the program executable you want to use, and then give it the file path/name as a parameter.

1 Like

Hi @postwick,

The Start Process activity much like Run command from start menu should know for a given file which default application to use. But for some reason the new community version says the image is not open. Start process opens the image so it works like before but fails after it opens the image.

This worked before and works now too (Opens the Image file using default application) but with a added error which is weird
For completeness. The error shown after the successful execution.

@camilacalderon What @postwick meant is to use either CMD or PowerShell to open the picture in the default photo viewer application in your host machine.


1 Like

Thank you! so from what I understand the start processes activity has errors when opening the images?

Hi @camilacalderon,

It works well. Start Process is a great activity for a simple task like this.

Just use the second approach as @postwick suggested.

You have to tell the Host PC please use PowerShell or CMD and then open your image (this will work on most image extensions supported by your default image viewer)

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"  ( in Windows 10)
1 Like

Thank you so much for your help! @jeevith @postwick

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