I would like to count number of files inside a specific folder and open each file or only .png files. can anyone know about this??
Get folder file count
you can use
System.IO.DirectoryInfo myDir= new System.IO.DirectoryInfo(“SourcePath”);
int count = myDir.GetFiles().Length;
or below approach as well.
you can use for-each looping construct with
Directory.GetFiles("FOLDER_PATH","*.*",SearchOption.AllDirectories) and inside it using If condition by using Path.GetExtension(item)=".png".
for reference flow understanding for you:sample.xaml (7.1 KB)
Note- Replace the folder path with your directory path.
tq aksh… it worked for me
I want to do exactly the same but with excel-files. I do Path.GetExtension(item)=".xls". But this throws me an error: " …Disallows implicit conversions from ‘Object’ to ‘String’ " … Any ideas what Im doing wrong?
EDIT: Wrong type argument.
GO to for Each -> TypeArgument -> Change TypeArgument from Object to String