好的,
我有一个文件列表(仅包含文件名的 SourceFile 对象),然后我想从 zip 中提取这些特定文件并将它们转储到临时目录中,以便以后分发它们。
我想出了这个,但我不确定下一步如何进行..
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;
}
供参考:
public class SourceFile
{
public string Name { get; set; } //ex. name = "Fred.dll"
}