Do not specify the full path of a file. Find it only by name

Hello everyone I would like to know how I can not specify the full path of an Excel file, but find it only by name. I’ve searched for information in other forums and I think you should use this function

Directory.GetDirectories ("C:\Users\Desktop"). Select (Function (f) path.getfilename (f)) .ToArray

but I do not know how to use it properly. can you explain please

1 Like

Here’s one approach using an Invoke Code activity along with Directory.EnumerateFiles. The activity returns either a single file name or null (Nothing), and you can use control structures to verify whether your file was there or not. Note that this also supports searching all sub directories.

filename = Directory.EnumerateFiles("C:\Temp", "out.png", SearchOption.AllDirectories).FirstOrDefault()

filename is the activity’s only Out argument.


Hello, thank you very much for your response, I followed the steps you gave me and the file finds it but I do not know how to do it so that only the name of the file can be placed on the route and not all the content of the route

example of how I have it

“C:\Users\crojas\Desktop\RCO_PlaneacionPartesRDC\Planeacion de compra”+“_”+DatePF.ToString+“.xlsx”

What I need is for it to be this way

“Planeacion de compra”+“_”+DatePF.ToString+“.xlsx”

1 Like