2
確定提取特定的文件,SharpZipLib〜如何從一個zip
我有文件的列表(這只是只包含文件名的SourceFile對象),那麼我想拉這些特定的文件了拉鍊和甩掉他們進入臨時目錄,以便以後可以分發它們。
我想出了這一點,但我對接下來該怎麼繼續不確定..
private List<string> ExtractSelectedFiles()
{
List<SourceFile> zipFilePaths = new List<SourceFile>();
List<string> tempFilePaths = new List<string>();
if (!File.Exists(this.txtSourceSVNBuildPackage.Text)) { return tempFilePaths; };
FileStream zipFileStream = File.OpenRead(this.txtSourceSVNBuildPackage.Text);
ZipInputStream inStream = new ZipInputStream(zipFileStream);
foreach (SourceFile currentFile in _selectedSourceFiles)
{
bool getNextEntry = true;
while (getNextEntry)
{
ZipEntry entry = inStream.GetNextEntry();
getNextEntry = (entry != null);
if (getNextEntry)
{
if (fileType == ".dll")
{
if (sourcefile.Name == Path.GetFileName(entry.Name))
{
//Extract file into a temp directory somewhere
//tempFilePaths.Add("extractedfilepath")
}
}
}
}
}
return tempFilePaths;
}
FYI:
public class SourceFile
{
public string Name { get; set; } //ex. name = "Fred.dll"
}