Reputation: 1217
Like the title says, I need to read the names of files from a zip file. I'm going to feed the names into a 2D string array (along with other data). Here's a beginning example of what I'd like to do.
private String[,] ArrayFiller(ZipFile MyZip)
{
int count = 0;
ZipFile zipfile = ZipFile.Read();
int zipSize = MyZip.Count;
string[,] MyArr = new string[zipSize, zipSize];
foreach (ZipEntry e in zipfile.EntriesSorted)
{
//otherArr[count,count] = e; -adds the file, but I need title
}
return MyArr;
}
I'm sure I'm missing something simple, but I can't seem to find a "file name" property within the ZipFile class. The imported package is called Ionic.Zip.
Maybe it's a property of some kind of zipped object?
Upvotes: 2
Views: 7456
Reputation: 461
You might have more luck with the ZipArchive class.
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
// The file name is entry.FullName
}
}
Upvotes: 3