/// <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); } }
private bool LoadProject(string filename) { PackageClass pak = new PackageClass(); if (!pak.Load(filename)) { MessageBox.Show("Error loading package project"); return(false); } pak.GenerateAbsolutePath(Path.GetDirectoryName(filename)); foreach (FolderGroup folderGroup in pak.ProjectSettings.FolderGroups) { ProjectSettings.UpdateFiles(pak, folderGroup); } pak.ProjectSettings.ProjectFilename = filename; Package = pak; mruMenu.AddFile(filename); return(true); }
/// <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; } }