Extract File name from a direstory

Hi
I need to perform particular operation on files which is ending with -Trial Balance.xlsx. I am trying with Directory.GetFiles(selectFolder, “TrialBalance.xlsx”). But it is not working. Can anyone help me with it.

Thanks

to get the listt of xlsx files from a folder
arr_files = Directory.GetFiles(“yourfolderpath”,"*.xlsx")
where arr_files is a variable of type array of string

now use a for each loop and pass the above variablle as input and change the type argument as string in the property panel of for each activity
–inside the loop to get the file name
use this expression in writeline
Path.GetFilename(item.ToString)

Cheers @Ankita_Biswas_SDC_Ko

@Ankita_Biswas_SDC_Ko,

The below query with return you the list of excel files which contains “TrialBalance.xlsx” in its name. This will return List(Of FileInfo) - so you can loop and use it with FileInfo as the looping Object.

Directory.GetFiles(strDesktop).[Select](Function(f) New FileInfo(f)).Where(Function(f) (f.Extension.Equals(".xlsx") AndAlso (f.Name.Contains("TrialBalance"))).ToList()

I am getting validation error in this one.

Hi @Ankita_Biswas_SDC_Ko

You were almost there.

Directory.GetFiles(selectFolder, “*TrialBalance.xlsx”)

1 Like

@Ankita_Biswas_SDC_Ko,

Check this xaml, it has the logic for your requirement.
GetExcelFileLikeNameFilter.xaml (6.0 KB)

1 Like

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