Error BC30311 Value of type 'FileInfo' cannot be converted to 'String'

Hello there.

I have a For Each File In Folder activity, but I keep getting an error:
Error BC30311 Value of type ‘FileInfo’ cannot be converted to ‘String’

I just want to rename a file (excel) in a folder, but the difficulty is that the file (downloaded) has every download a new name… See screenshot. Thanks in advance!

Use CurrentFile.FullName

Hello @Brooss
Use Filter By Properties–> Mention the File Extension with Asterisks like *xlsx. It will get only Excel files with specific Extensions.
Use Currentfile.ToString or CurrentFile.FullName to get the Full path of the file in a loop

Hi

The error `Error BC30311 Value of type ‘FileInfo’ cannot be converted to ‘String’” is caused by the fact that the For Each File In Folder activity returns an array of FileInfo objects, which is a different type than a string. To fix this error, you need to convert the FileInfo object to a string before you use it in the Rename File activity.

As Peter mentioned set the FilePath property to the following expression:

CurrentFile.FullName

This expression will get the full path of the current file in the loop.

Cheers

it works. thanks so much for the clean and fast replies from all of you!

To get more info about the file info we would like to reference the official docu

We do feel that the question is answered and the topic can be closed
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

1 Like

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