|
楼主 |
发表于 2013-7-11 01:19:27
|
显示全部楼层
public void Changyong()
{
DirectoryInfo dicInfo = new DirectoryInfo(@"D:\桌面管理文件夹\系统工具\");
FileInfo[] textFiles = dicInfo.GetFiles("*" + listBox1.Text + "*.*", SearchOption.TopDirectoryOnly);
foreach (FileInfo fileInfo in textFiles)
{
listBox1.Items.Add(fileInfo.FullName); //获取遍历路径
Icon ico = Icon.ExtractAssociatedIcon(fileInfo.FullName);//ExtractAssociatedIcon获取图标
img.Add(ico.ToBitmap()); //把图标集放入数组
ljn.Add(fileInfo.FullName); //路径集合
imageList1.Images.Add(ico); //图片集合
ljname.Add(Path.GetFileNameWithoutExtension(fileInfo.FullName));
for (int j = 0; j < ljname.Count; j++) //遍历程序名称
{
listView1.Items.Add(ljname[j]);
for (int i = 0; i < imageList1.Images.Count; i++) //遍历程序图标
{
this.listView1.Items[i].ImageIndex = i;
}
}
}
} |
|