How to fetch the total number of files present in a folder and store it in a variable?
Hi @vivek_Chowdary,
Directory.getfiles(“folderpath”) , the output of the expression store in an array variable and use write line to print the count arrfiles.length.tostring will give you how many files in a particular folder
Another solution:
// searches the current directory and sub directory
int fCount = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Length
// searches the current directory
int fCount = Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly).Length
Regards,
Karthik Byggari
Can you please try : Directory.GetFiles(Config(“Folder_Path”).ToString).Count
The above will give you the count of files present in the directory.
You can store the count value in a variable as below:
int fileCount = Directory.GetFiles(Config(“Folder_Path”).ToString).Count
Let me know if this is the solution that you are looking for.
Thanks a lot.