/// <summary> /// Loads the specified zipfile. /// /// </summary> /// <param name="zipfile">The zipfile.</param> /// <returns>if something wrong, return null else the loaded package</returns> public PackageClass Load(string zipfile) { try { PackageClass pak = new PackageClass(); _zipPackageFile = ZipFile.Read(zipfile); string tempPackageFile = Path.GetTempFileName(); var fs = new FileStream(tempPackageFile, FileMode.Create); _zipPackageFile["MediaPortalExtension.xml"].Extract(fs); fs.Close(); pak.Load(tempPackageFile); _tempFileList.Add(tempPackageFile); foreach (FileItem fileItem in pak.UniqueFileList.Items) { if (fileItem.SystemFile) { string tempfil = Path.GetTempFileName(); tempfil = Path.Combine(Path.GetDirectoryName(tempfil), Path.GetFileNameWithoutExtension(tempfil) + Path.GetExtension(fileItem.LocalFileName)); Extract(fileItem, tempfil); fileItem.TempFileLocation = tempfil; //fileItem.LocalFileName = tempfil; _tempFileList.Add(tempfil); } } pak.ZipProvider = this; pak.GetFilePaths(); pak.GeneralInfo.Location = zipfile; return(pak); } catch (Exception) { if (_zipPackageFile != null) { _zipPackageFile.Dispose(); } return(null); } }
/// <summary> /// Loads the specified zipfile. /// /// </summary> /// <param name="zipfile">The zipfile.</param> /// <returns>if something wrong, return null else the loaded package</returns> public PackageClass Load(string zipfile) { try { PackageClass pak = new PackageClass(); _zipPackageFile = ZipFile.Read(zipfile); string tempPackageFile = Path.GetTempFileName(); var fs = new FileStream(tempPackageFile, FileMode.Create); _zipPackageFile["MediaPortalExtension.xml"].Extract(fs); fs.Close(); pak.Load(tempPackageFile); _tempFileList.Add(tempPackageFile); foreach (FileItem fileItem in pak.UniqueFileList.Items) { if (fileItem.SystemFile) { string tempfil = Path.GetTempFileName(); tempfil = Path.Combine(Path.GetDirectoryName(tempfil), Path.GetFileNameWithoutExtension(tempfil) + Path.GetExtension(fileItem.LocalFileName)); Extract(fileItem, tempfil); fileItem.TempFileLocation = tempfil; //fileItem.LocalFileName = tempfil; _tempFileList.Add(tempfil); } } pak.ZipProvider = this; pak.GetFilePaths(); pak.GeneralInfo.Location = zipfile; return pak; } catch (Exception) { if (_zipPackageFile != null) _zipPackageFile.Dispose(); return null; } }