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

Team,
I’m using below assign activity to assign first csv file of directory to variable str_arr_inputfile and using for each activity as below :
Pls let me know any suggestions/solution for Error

CODE :
str_arr_inputfile = Directory.GetFiles(str_Downloads_FolderPath,“*.csv”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
for each item in str_arr_inputfile

ERROR :
For Each: Unable to cast object of type ‘System.Char’ to type ‘System.String’.

@prerna.gupta

ToList is what you need to write…ToList(0) will take only the first file directly

cheers

I only need to read the first file in directory due to which using ToList(0)

@prerna.gupta

Then why are you using For each?

cheers

Error
As in above im using the value of item and performing needful

@prerna.gupta

As already its the single file path you dont need to use loop…you can directly use move file with str_arr_Inputfile…

If you use for loop in the string variable then it breaks it into characters which you dont need

cheers

if i do not use foe each loop, then while suing move command what value will be passed in item ? As item is dynamic value

@prerna.gupta

Instead of item pass str_arr_Inputfile

You will use for loop if you have a array of files and if you need toa ccess each…but now you already are getting only single file you just need to move that

cheers

Let me try this option
Thanks