<pre lang="C#"> if (CSI.DisplayName.Equals(CShItem.strMyComputer)) { dirList = CSI.GetDirectories(); // this line is throwing HRESULT E_FAIL exception }
CShItem chitem2 = new CShItem("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); AfterNodeSelect("This PC", chitem2); BackItemStack.Add("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"); ItemCount = BackItemStack.Count; btnBack.Enabled = true;
try { ArrayList dirList = new ArrayList(); ArrayList fileList = new ArrayList(); int TotalItems = 0; LastSelectedCSI = CSI; if (CSI.DisplayName.Equals(CShItem.strMyComputer)) { dirList = CSI.GetDirectories(); } else { dirList = CSI.GetDirectories(); fileList = CSI.GetFiles(); } Event1.WaitOne(); TotalItems = dirList.Count + fileList.Count; if (TotalItems > 0) { dirList.Sort(); fileList.Sort(); //pathName = "N:\VE\Job2011" this.Text = pathName; sbr1.Text = pathName; ArrayList combList = new ArrayList(TotalItems); combList.AddRange(dirList); combList.AddRange(fileList); //Build the ListViewItems & add to lv1 lv1.BeginUpdate(); lv1.Items.Clear(); lv1.Refresh(); foreach (CShItem item in combList) { ListViewItem lvi = new ListViewItem(item.DisplayName); if ((item.IsDisk & item.IsFileSystem) == Convert.ToBoolean(0)) { FileAttributes attr = (FileAttributes)Microsoft.VisualBasic.FileSystem.GetAttr(item.Path); StringBuilder SB = new StringBuilder(); if ((attr & FileAttributes.System) == FileAttributes.System) { SB.Append("S"); } if ((attr & FileAttributes.Hidden) == FileAttributes.Hidden) { SB.Append("H"); } if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { SB.Append("R"); } if ((attr & FileAttributes.Archive) == FileAttributes.Archive) { SB.Append("A"); } lvi.SubItems.Add(SB.ToString()); } else { lvi.SubItems.Add(""); } if ((item.IsDisk & item.IsFileSystem & !item.IsFolder) == Convert.ToBoolean(0)) { if (item.Length > 1024) { lvi.SubItems.Add((item.Length / 1024.0).ToString("#,### KB")); } else { lvi.SubItems.Add(item.Length.ToString("##0 Bytes")); } } else { lvi.SubItems.Add(""); } lvi.SubItems.Add(item.TypeName); if (item.IsDisk) { lvi.SubItems.Add(""); } else { if (item.LastWriteTime == testTime) //"#1/1/0001 12:00:00 AM#" is empty { lvi.SubItems.Add(""); } else { lvi.SubItems.Add(item.LastWriteTime.ToString()); } } //.ImageIndex = SystemImageListManager.GetIconIndex(item, False) lvi.Tag = item; lv1.Items.Add(lvi); } lv1.EndUpdate(); LoadLV1Images(); } else { lv1.Items.Clear(); sbr1.Text = pathName + " Has No Items"; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)