Get files from folder

Hi,
i have a folder with 20 files. But i want to get files only with keywords “part” or"error" in the file name.how do i do that

Hi @amruta_George ,

You could try with the below approach :

Directory.GetFiles("YourFolderPath").Where(Function(x){"part","error"}.Any(Function(y)Path.GetFileName(x).ToLower.Contains(y))).ToArray

Let us know if this doesn’t work

no this is not working

hi @amruta_George ,

Please use this code in assign activity and the output will be a array of filenames

Directory.GetFiles(“D:\fasil_docs\Documents”).AsEnumerable().Where(function(x) Path.GetFileName(x.ToString).Contains(“part”) or Path.GetFileName(x.ToString).Contains(“error”)).ToArray

Change the folder path as required

image

This worked.thank you

1 Like

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