string []arrSubItem=new string[4];
//文件的创建时间和访问时间。
int iCount=0; int iconIndex=1;//用1,而不用0是要让过0号图标。
foreach(FileInfo fileInfo in dirFiles)
{
string strFileName=fileInfo.Name;
//*************************************************************************************
[DllImport("Shell32.dll")]
public static extern int ExtractIcon(IntPtr h,string strx,int ii);
[DllImport("Shell32.dll")]
public static extern int SHGetFileInfo(string pszPath,uint dwFileAttributes,ref SHFILEINFO psfi,uint cbFileInfo, uint uFlags);
public struct SHFILEINFO
{
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
public char szDisplayName;
public char szTypeName;
}
int iImageIndex=4; int iSelectedIndex=5;
foreach (DirectoryInfo di in adirinfo)
{
if(di.Name=="RECYCLER"||di.Name=="RECYCLED"||di.Name=="Recycled")
{iImageIndex=6; iSelectedIndex=6;}
else
{iImageIndex=4; iSelectedIndex=5;}
TreeNode tnDir = new TreeNode(di.Name, iImageIndex, iSelectedIndex);
tn.Nodes.Add(tnDir);
}
/*
//获得当前目录下的所有文件
FileInfo[] dirFiles;
dirFiles=dirinfo.GetFiles();
int iCount=7;
foreach (FileInfo fi in dirFiles)
{
//得到每个文件的图标
string str=fi.FullName;
try
{
SetIcon(TreeImageList,str,false);
}
catch(Exception ex)
{ MessageBox.Show(ex.Message,"错误提示",0,MessageBoxIcon.Error);}
TreeNode tnDir = new TreeNode(fi.Name, iCount, iCount);
tn.Nodes.Add(tnDir);
string []arrSubItem=new string[4];
//文件的创建时间和访问时间。
int iCount=0; int iconIndex=1;//用1,而不用0是要让过0号图标。
foreach(FileInfo fileInfo in dirFiles)
{
string strFileName=fileInfo.Name;
//C#资源管理器源码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Runtime.InteropServices;