How to search particular file in folder and copy that file

Hi guys,

i want to search particular file in a folder by using file name(it varies every time, i am passing variable)
and i need to copy that file for further process.

How can i do it ?

kindly help :slight_smile:
Thanks in advance

1 Like

use file.exist(“File_Path”) this will give you Boolean value if it is true then copy the file.

@asha_TN

Try like this:

    requiredFile[] = Directory.GetFiles("FolderPath",varFile+"*") 

Then use Copy File activity and pass like requiredFile(0).

Hi
Hope this expression would help you resolve this
Use a assign activity like this
str_filepath = Directory.GetFiles(“yourfolderpath”,variablename+”.*”)

Where str_filepath is a variable of type string

Cheers @asha_TN

@asha_TN,

Check with the below code, it will return List(Of FileInfo),

Directory.GetFiles("YourDirectoryPath").[Select](Function(f) New FileInfo(f)).Where(Function(f) f.Name.Contains("yourSearchValue")).ToList() 

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