Find excel file in the Directory where file name name starts from particular word


I have folder with excel files:
Find Excel
Each month folder will be update and name of excel file will be updated too.
I need to open excel file that starts from word ‘Total’, only word ‘Total’ in the name of excel file will be unchangebale, other parts will be changed.
Which activites should I use to open excel file where name starts from word ‘Total’ and copy sheet content into another excel file?

HI ,

  1. Get the Files list from the Directory where File name Starts with Total
  2. Copy content From Source File to Destination

I need to scan each file name and find the file that starts with ‘Total’
How to do it?

If System.IO.Directory.GetFiles("C:\Temp\","Total*").Count > 0 Then
str_FilenPath = System.IO.Directory.GetFiles("C:\Temp\","Total*")(0)
end if
1 Like

Path to the folder is stored like this: “Path.Combine(YourPath,LastMonth)”
Following your suggestion I wrote: System.IO.Directory.GetFiles(“Path.Combine(YourPath,LastMonth)”,“Total*”)(0)
but it gets error: Could not find a part of the path

1 Like

Can you please my command?

in your case it should be like:

Path.Combine should not be in double quotes


It worked! Thank you!

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