Hi,
I have a c# program which will unzip all the zipped file.But I need to open the unzipped folder and visible only .txt files.How can I do that?
below code will unzip all files but i want to open that folder and get only selected files(.txt or .xlsx)
in my destination path(here extractPathForCurrentZip) i shoud only see .txt files from diffrent unzipped folder
my code to unzip:
C#
string startPath = @"C:\zipdirectory\";
string extractPath = @"C:\unzipdirectory\";
Directory.GetFiles(startPath, "*.zip", SearchOptions.AllDirectories).ToList()
.ForEach(zipFilePath => {
var extractPathForCurrentZip = Path.Combine(extractPath, Path.GetFileNameWithoutExtension(zipFilePath));
if(!Directory.Exists(extractPathForCurrentZip))
{
Directory.CreateDirectory(extractPathForCurrentZip);
}
ZipFile.ExtractToDirectory(zipFilePath, extractPathForCurrentZip);
});
Amit MohantyRank #112 · 20K reputationPosted Apr 14, 2022, 1:49 AM EDT
Sujeet RamanRank #1,329 · 1.3K reputationPosted Apr 14, 2022, 10:17 AM EDT