For Each: Unable to cast object of type 'System.String' to type 'System.String[]'

Hello, guys.

455/5000

I’m trying to iterate through the files of a directory. I am using the System.IO.Directory.GetFiles () function to extract the file names in the directory and I am saving the function return in a System.String . To iterate through this array, I’m using a for each, with the system.string argument as well. But I am encountering this error:
For Each: Unable to cast object of type ‘System.String’ to type ‘System.String ’.

What can it be?

@Gilberto_Marinho

Specify Type Argument as String and then try it once.

1 Like

where should i specify? in for each, in the variable or both?

@Gilberto_Marinho

Change it under Type argument field.

1 Like

TypeArgument is highlighted with a red box in the screenshot. That should be String instead of System.String

1 Like

Hi @Gilberto_Marinho

please find below screenshot.

I have created workflow based on your requirement please find below attached workflow run and check you will get solution.

GetFileNames.zip (27.9 KB)

Regards,
Kommi Jeevan.

1 Like

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