Step 1: Add System.IO.Compression and System.IO.Compression.File in the proj and then add the bewlo code
private void CopyToDestination_Click(object sender, EventArgs e)
{
string sourcePath = ConfigurationManager.AppSettings["SourceLoaction"];
string destinationPath = ConfigurationManager.AppSettings["DestinationLocation"];
string[] copyfiles = CSVTextBox.Text.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
string[] copyPDF = ImageFileTextBox.Text.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var filestToCopy in copyfiles)
{
//string zipPath = @"\\ncfile05\SCIOmineDev_CN\Rupesh\MRM\zip\" + filestToCopy + "";
//string extractPath = @"\\ncfile05\SCIOmineDev_CN\Rupesh\MRM\zip\pdf";
string zipPath = @ConfigurationManager.AppSettings["SourceLoaction"] + filestToCopy + "";
string extractPath = @ConfigurationManager.AppSettings["DestinationLocation"];
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
foreach (var pdfFileToCopy in copyPDF)
{
if (entry.FullName.EndsWith(pdfFileToCopy, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(entry.FullName);
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName),true);
}
}
}
}
}
}
private void CopyToDestination_Click(object sender, EventArgs e)
{
string sourcePath = ConfigurationManager.AppSettings["SourceLoaction"];
string destinationPath = ConfigurationManager.AppSettings["DestinationLocation"];
string[] copyfiles = CSVTextBox.Text.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
string[] copyPDF = ImageFileTextBox.Text.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var filestToCopy in copyfiles)
{
//string zipPath = @"\\ncfile05\SCIOmineDev_CN\Rupesh\MRM\zip\" + filestToCopy + "";
//string extractPath = @"\\ncfile05\SCIOmineDev_CN\Rupesh\MRM\zip\pdf";
string zipPath = @ConfigurationManager.AppSettings["SourceLoaction"] + filestToCopy + "";
string extractPath = @ConfigurationManager.AppSettings["DestinationLocation"];
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
foreach (var pdfFileToCopy in copyPDF)
{
if (entry.FullName.EndsWith(pdfFileToCopy, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(entry.FullName);
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName),true);
}
}
}
}
}
}
No comments:
Post a Comment