private void DisplayZIPOnTree(ZipRemoteFile zipFile) { checkableTreeView1.ImageList = FileTypeImageList.GetSharedInstance(); checkableTreeView1.Nodes.Clear(); foreach (ZipEntry entry in zipFile) { // skip folders... if (entry.Name.EndsWith("/")) { continue; } string displayName; TreeNode parentNd = GetNodeFromPath(entry.Name, out displayName); TreeNode newNd = new TreeNode(displayName); newNd.Tag = entry; newNd.ImageIndex = FileTypeImageList.GetImageIndexByExtention(Path.GetExtension(entry.Name)); newNd.SelectedImageIndex = newNd.ImageIndex; if (parentNd == null) { checkableTreeView1.Nodes.Add(newNd); } else { parentNd.Nodes.Add(newNd); } } }
private void LoadZIP() { checkableTreeView1.Nodes.Clear(); ResourceLocation rl = this.DownloadLocation; rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { chkChooseZIP.Checked = false; MessageBox.Show("Invalid URL format, please check the location field.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ReleaseZIPThread(); zipReaderThread = new Thread( delegate(object state) { ZipRemoteFile zipFile = new ZipRemoteFile((ResourceLocation)state); try { if (zipFile.Load()) { this.BeginInvoke((MethodInvoker) delegate() { DisplayZIPOnTree(zipFile); waitControl1.Visible = false; }); } else { this.BeginInvoke((MethodInvoker) delegate() { waitControl1.Visible = false; MessageBox.Show("Unable to load ZIP contents.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); }); } } catch (Exception ex) { this.BeginInvoke((MethodInvoker) delegate() { waitControl1.Visible = false; MessageBox.Show("Unable to load ZIP contents: " + ex.Message, AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); }); } } ); waitControl1.Visible = true; zipReaderThread.Start(rl); }