public void AddFile(TreeListViewItem node, string fsFullPath) { try { FileInfo diChild = new FileInfo(fsFullPath); string strExt = diChild.Extension.ToLower(); if (strExt == ".exe") { strExt = diChild.FullName.ToLower(); } Shell32.SHFILEINFO shFileInfo = new Shell32.SHFILEINFO(); Icon SmallIcon = Apq.Windows.Forms.IconChache.GetFileSystemIcon(diChild.FullName, ref shFileInfo); TreeListViewItem ndChild = new TreeListViewItem(diChild.Name); node.Items.Add(ndChild); if (node.CheckStatus != CheckState.Indeterminate) { ndChild.Checked = node.Checked; } ndChild.ImageIndex = _imgList.Images.IndexOfKey(strExt); ndChild.SubItems.Add(diChild.Length.ToString("n0")); if (strExt.Contains("\\")) { strExt = "应用程序"; } ndChild.SubItems.Add(shFileInfo.szTypeName); ndChild.SubItems.Add(diChild.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")); ndChild.SubItems.Add(diChild.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")); ndChild.SubItems.Add(diChild.Name); ndChild.SubItems.Add("-1"); ndChild.SubItems.Add("3");//类型{1:Drive,2:Folder,3:File} } catch { } }
void FSExplorer_BeforeExpand(object sender, TreeListViewCancelEventArgs e) { if (e.Item.Level > 0) { if (e.Item.ImageKey == "文件夹收起") { Shell32.SHFILEINFO shFolderInfo = new Shell32.SHFILEINFO(); Apq.Windows.Forms.IconChache.GetFileSystemIcon(e.Item.FullPath, ref shFolderInfo, true); e.Item.ImageKey = "文件夹展开"; } } }