for example let us consider I have the files more then 1000 in a folder and I need to compare the Files with their names.
Like the every file name should be compared with the input file name receiving and if the file name matches then that’s a duplicate file otherwise that’s a non-duplicate file.
Kindly help with the any LINQ query for this issue.
Assign activity:
nonDuplicateFiles = allFiles.Where(Function(f) Not Path.GetFileName(f).Equals(inputFileName)).ToList()
Note: Read All File Names : Use Directory.GetFiles(FolderPath) Compare File Names : Use a LINQ query to compare each file name against the input file name to identify duplicates.
inputFileName = "your_input_file_name_here.pdf" ' Change this to your input file name
duplicateFiles = Directory.GetFiles("your_folder_path_here")
.Where(Function(filePath) Path.GetFileName(filePath) = inputFileName)
.ToArray()