public void Initialise(IntPtr pidl, string path) { this.PIDL = pidl; this.RelativePIDL = ILShell32.ILFindLastID(pidl); IntPtr folderPidl = PIDL; SHFILEINFO?info = PidlManager.GetShFileInfo(pidl); var dir = System.IO.Path.GetDirectoryName(path); if ((info.Value.Attributes & SFGAO.SFGAO_FOLDER) == 0) { // Item folder var handle = PidlManager.FromPath(dir); folderPidl = handle.pidl; SHFILEINFO?info2 = PidlManager.GetShFileInfo(folderPidl); if (!info2.HasValue) { return; // new DirectoryNotFoundException } ParentItem = new ShellItem(); ParentItem.PIDL = folderPidl; ParentItem.RelativePIDL = ILShell32.ILFindLastID(folderPidl); ParentItem.DisplayName = info2.Value.szDisplayName; ParentItem.Attributes = (SFGAO)info2.Value.Attributes; ParentItem.IsFolder = (Attributes & SFGAO.SFGAO_FOLDER) != 0; ParentItem.IsFileSystem = (Attributes & SFGAO.SFGAO_FILESYSTEM) != 0; } //IShellItem i = ILShell32.SHCreateItemFromParsingName(path, IntPtr.Zero, // typeof(IShellItem).GUID); int hr = 0; IShellFolder pShellFolderInterface = IFolder(folderPidl, desktopShellFolder.Value.ShellFolderInterface, ref hr); if (pShellFolderInterface == null) { throw new NullReferenceException("SheelObject ShellFolderInterface error"); } DisplayName = info.Value.szDisplayName; Attributes = (SFGAO)info.Value.Attributes; IsFolder = (Attributes & SFGAO.SFGAO_FOLDER) != 0; IsFileSystem = (Attributes & SFGAO.SFGAO_FILESYSTEM) != 0; if ((info.Value.Attributes & SFGAO.SFGAO_FOLDER) == 0) { this.ParentItem.InitFolder(folderPidl, dir, pShellFolderInterface, false); } else if (dir == null && path.EndsWith(@":\")) { this.InitFolder(PIDL, path, pShellFolderInterface, false); } else { this.InitFolder(PIDL, dir, pShellFolderInterface, false); } }