XapEditor.Xap.Open C# (CSharp) Method

Open() public method

public Open ( ) : void
return void
        public void Open()
        {
            if(File.Exists(Source))
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(Source)))
            {
                ZipEntry theEntry;
                if (Directory.Exists(Root)) Directory.Delete(Root, true);
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = Root;
                    string ld = Path.GetDirectoryName(theEntry.Name);
                    if(ld.Length > 0) directoryName += string.Concat("\\", ld);
                    string fileName = Path.GetFileName(theEntry.Name);
                    bool ex = Directory.Exists(directoryName);
                    if (directoryName.Length > 0 && false == ex)
                        Directory.CreateDirectory(directoryName);
                    if (fileName != String.Empty)
                    {
                        string p = string.Concat(directoryName, "\\", fileName);
                        using (FileStream streamWriter = File.Create(p))
                        {
                            //List.Add(new XapEntry(p, this));
                            int size = 2048;
                            byte[] data = new byte[2048];
                            while (true)
                            {
                                size = s.Read(data, 0, data.Length);
                                if (size > 0) streamWriter.Write(data, 0, size);
                                else break;
                            }
                        }
                    }
                }
                RefreshList();
                GetMetadata();
            }
        }
        public void RefreshList()

Usage Example

 public bool OpenXap(string fp)
 {
     xap = new Xap(fp);
     xap.Open();
     dgXap.ItemsSource = xap.List;
     dAppName.Text     = xap.Meta["Title"];
     try { dImage.Source = StaticBitmap.Read(xap.GetIcon()); }
     catch (Exception) { }
     dAppProp.Text          = string.Format("Version {3} ({4})\rAuthor: {0}\rPublisher: {2}", xap.Meta["Author"], xap.Meta["Genre"], xap.Meta["Publisher"], xap.Meta["Version"], xap.Meta["RuntimeType"], xap.Meta["ProductID"]);
     menu_pack.IsEnabled    = true;
     leftCol.MinWidth       = 5;
     leftCol.Width          = new GridLength(300);
     menu_close.IsEnabled   = true;
     menu_savexap.IsEnabled = true;
     SaveRecent("RecentXap", xap.Source);
     LoadRecent("RecentXap", "menu_recentxap");
     return(true);
 }
All Usage Examples Of XapEditor.Xap::Open