Get the Filename with and without extension in UiPath
While working on any scenario in Automation you need to know these two steps.
A lot of times we need to know the file name as part of developing the automation workflows.
How do we do that?
First step is to get the full path of the file name from the Folder.
How to get file name with extension?
Take an Assign activity and get the files from the folder using this syntax as below by creating a File_Path Array of a string variable:
filepath is a variable which is the full path of the folder where the input files are present.
Now take a for each to iterate each file in the folder:
The syntax to get the file name with extension is mentioned above (System.IO.Path.GetFileName(item.ToString)).
This will give you only file name with extension from full file path.
How to get the file name without extension?
Now in the same for each activity change the assign and create a variable to store the file name without extension.
The syntax to get the file name without extension is this System.IO.Path.GetFileNameWithoutExtension(item.ToString).
This will give you the file name without extension from full file path.