Zvonko
asked on
open System.IO.Compression.ZipArchiveEntry as ZipFile without storing to file
My Zip files contain among other entries also Zip files with many entries inside the inner zip file.
How can I read the inner zip file entries attributes without having to store the inner zip file to disk?
I need this in JavaScript (dot.Net 4.5) but a C# example is fine for me.
Here me code snippet where I need help:
How can I read the inner zip file entries attributes without having to store the inner zip file to disk?
I need this in JavaScript (dot.Net 4.5) but a C# example is fine for me.
Here me code snippet where I need help:
if(blnZipFile){
try{
var arrFiles = Directory.GetFiles(strFolder, "*.zip", SearchOption.AllDirectories);
for(var z=0;z<arrFiles.length;z++){
var zipFileName = arrFiles[z];
//print("Zip: "+zipFileName);
try{
var zipArchive = System.IO.Compression.ZipFile.OpenRead(zipFileName);
for(var i=0;i<zipArchive.Entries.Count;i++){
var zipEntry = zipArchive.Entries[i];
if(zipEntry.Name.match(/imsmanifest.xml/i)){
try{
var xmlReader = new StreamReader(zipEntry.Open());
var xmlString = xmlReader.ReadToEnd();
xmldoc.LoadXml(xmlString);
var strTitle = "";
var xmlTitle = xmldoc.DocumentElement.SelectSingleNode("//*[local-name()='title']");
if(xmlTitle) strTitle = xmlTitle.InnerText.toString();
var strModDate = zipEntry.LastWriteTime.LocalDateTime;
var strCurrFolder = Path.GetDirectoryName(zipFileName);
var arrLinkFiles = Directory.GetFiles(strCurrFolder, "*.lnk", SearchOption.TopDirectoryOnly);
var blnLinkFound = (arrLinkFiles.length > 0);
addExcelRow(strTitle,intState,zipFileName+"; "+zipEntry.FullName,strModDate,blnLinkFound);
} catch(e){
print(" *** error for: "+zipFileName+"["+zipEntry.Name+"]"+"\n\t"+e.message);
}
}
if(zipEntry.Name.match(/\.zip$/i)){
print("Open zip: "+zipEntry.Name);
var zipEntryStream = zipEntry.Open();
var zipInnerArch = System.IO.Compression.ZipArchive(zipEntry.Open(),System.IO.Compression.ZipArchiveMode.Read);
print("opened!")
for(var j=0;j<zipInnerArch.Entries.Count;j++){
var zipInnerEntry = zipArchive.Entries[j];
if(zipInnerEntry.Name.match(/imsmanifest.xml/i)){
print("manifest: "+zipInnerEntry.Name);
try{
var xmlReader = new StreamReader(zipInnerEntry.Open());
var xmlString = xmlReader.ReadToEnd();
xmldoc.LoadXml(xmlString);
print("imsloaded...");
var strTitle = "";
var xmlTitle = xmldoc.DocumentElement.SelectSingleNode("//*[local-name()='title']");
if(xmlTitle) strTitle = xmlTitle.InnerText.toString();
print("Title: "+strTitle);
var strModDate = zipInnerEntry.LastWriteTime.LocalDateTime;
var strCurrFolder = Path.GetDirectoryName(zipFileName);
var arrLinkFiles = Directory.GetFiles(strCurrFolder, "*.lnk", SearchOption.TopDirectoryOnly);
var blnLinkFound = (arrLinkFiles.length > 0);
addExcelRow(strTitle,intState,zipFileName+"; "+zipEntry.FullName+"; "+zipInnerEntry.FullName,strModDate,blnLinkFound);
print(": )");
} catch(e){
print(" *** error for: "+zipFileName+"["+zipInnerEntry.Name+"]"+"\n\t"+e.message);
}
}
}
}
};
} catch(e){
log(" *** failed, no info for: "+zipFileName);
}
}
} catch(e){
log(" *** failed, no info for Zip-Scan: "+strFolder);
}
}
I need help in this area:
if(zipEntry.Name.match(/\.zip$/i)){
print("Open zip: "+zipEntry.Name);
var zipEntryStream = zipEntry.Open();
var zipInnerArch = System.IO.Compression.ZipArchive(zipEntry.Open(),System.IO.Compression.ZipArchiveMode.Read);
print("opened!")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I solved it myself.
Regards,
Zvonko