I have folder structure like follow
Path of the main folder is
C:\Users\me\Desktop\main_folder\
withing that there can be any number of sub folders with any name.
what i need to do is go in to each of that sub folder and extract the zip files in it.
For this, in powerhsell we can use the path like follow which takes any sub folder in the given folder.
C:\Users\me\Desktop\main_folder\*\*.zip
but how to do this in C# ?
method that i'm trying to use is
System.IO.Directory.GetFiles("C:\Users\me\Desktop\main_folder\*\",
"*.zip",System.IO.SearchOption.TopDirectoryOnly);
Try this:
string root = @"C:\Users\me\Desktop\main_folder\";
var files =
Directory.EnumerateDirectories(root).SelectMany(
directory => Directory.EnumerateFiles(directory, "*.zip"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With