Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using ExpTreeLib (A Class Library for building Forms with a folder navigation TreeView and form specific ListViews that can be tailored for your application and behave like Windows Explorer).

Now my form has own Button named "My Computer". When i clicked on it, it will navigate to
the My Computer in the ExpTreeLib

but getting error Error HRESULT E_FAIL has been returned from a call to a COM component


I am getting error at the follwoing line

C#
<pre lang="C#">
if (CSI.DisplayName.Equals(CShItem.strMyComputer))
{
					dirList = CSI.GetDirectories();

// this line is throwing HRESULT E_FAIL exception
 }


What I have tried:

My Computer button code
C#
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;




AfterNodeSelect code


C#
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());
          }
Posted
Updated 18-Oct-21 11:58am
Comments
James Parsells 2021 20-Oct-21 0:14am    
It has been too long since I looked at this. I do not remember any version of ExpLib using COM, though I just might mis-remember.
I would suggest you set some appropriate breakpoints and step thru to set where the error occurs and determine which file/folder gives that error.
Devendra Sarang 20-Oct-21 3:45am    
Error message : Error Message [^


Getting on some codes likes


ExpTree1.RootItem = CShItem.GetCShItem("D:\\");


OR


CShItem CSI;
CSI.GetDirectories();
Devendra Sarang 20-Oct-21 2:21am    
right now it is giving exception when we click on "My Computer".

I am able to access other folders on desktop. It is throwing exception for "My Computer" only.

Is it windows 10 may be creating some problem ?
James Parsells 2021 22-Oct-21 14:11pm    
It is a problem related to Windows 10. There is no such Folder as "My Computer" on Windows 10. ExpLib normally is rooted in the DeskTop though there a way to root in another Folder.
How are you trying to access "My Computer"?
I don't believe that I ever released a version that made any allowance for Windows 10 though it is quite possible that almost no changes were required. I also think that the ExpLib you are using is a modification of one of the versions I did release.

1 solution

i see you've asked one question on this very old CP article by ExperTree's author, and, he has responded [^].

Why not post the code and this question there ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900