I have a folder, and within that folder is a subfolder, and within that subfolder is another subfolder, and within those folders and subfolders are files.
Ex - main folder
Subfolder 1
Subfolder 2
Subfolder 3
First, I must verify that all six files are present in those directories. If any of the files are missing, I must identify the missing file name and notify the team that this particular file is not present in this folder.
Name of files is - File 1 , File 2 , File 3 , File 4 , File 5 , File 6
Set a variable to hold the path of the main folder you want to search within. For example, folderPath = "C:\MainFolder".
Create an array or list variable to store the names of the files you want to verify. For example, fileNames = {"File1.txt", "File2.txt", "File3.txt", "File4.txt", "File5.txt", "File6.txt"}.
Utilize the Directory.GetFiles method to retrieve a list of all file paths within the main folder and its subfolders. Use the search option SearchOption.AllDirectories to include all subfolders recursively.
Iterate over each file name in the fileNames variable.
For each file name, use the File.Exists method to check if the file exists within the folder structure. Provide the full path to the file using Path.Combine(folderPath, fileName).
If a file is missing, log the missing file name and notify the team. You can use the Log Message activity or send an email with the missing file names.