Dynamic file name in Config File

Hi community!

I’m having an issue trying to write a dynamic path for the input data in the config file. The file name contains the data of today as yyyyMMdd (Planning 20220505 NA.xlsx). In the config file have written:
“Planning” + DateTime.Now.ToString(“yyyyMMdd”) + “NA.xlsx”

This is not working though.
Thank you for any help.

@roberto.piccolli

Welcome to our UiPath community.

Just mention source folder path in Config file.

And then try below expression to read dynamic filename in your code.

          Directory.GetFiles(in_Config("SourceFolderPath").ToString,"Planning"+Now.ToString("yyyyMMdd")+"NA.xlsx")(0)
1 Like

You can’t write code in the config file, only string values. What you can do instead is to add a placeholder and then replace it with String.Format(). E.g:

image

filename = String.Format(in_Config("PlanningFile").ToString, Now.ToString("yyyyMMdd"))

It works just fine with the given solution. Thank you, @ptrobot

1 Like

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