本文介绍了如何使用directoryinfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DirectoryInfo dir =新的DirectoryInfo
如何在我的代码中使用DirectoryInfo dir = new DirectoryInfo我的意思是说我拥有哪个类,包括
我在代码中使用这里,但这是错误
我必须包括的内容
DirectoryInfo dir = new DirectoryInfo
how to use DirectoryInfo dir = new DirectoryInfo in my code i means to say which class i have ti include
i am using here in my code but here is the error
what i have to include
private void Form2_Load(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo("@C:\\image1");
foreach (FileInfo file in dir.GetFiles())
{
try
{
this.imageList1.Images.Add(Image.FromFile(file.FullName));
}
catch
{
Console.WriteLine("This is not an image file");
}
}
this.listView1.View = View.LargeIcon;
this.imageList1.ImageSize = new Size(32, 32);
this.listView1.LargeImageList = this.imageList1;
//or
//this.listView1.View = View.SmallIcon;
//this.listView1.SmallImageList = this.imageList1;
for (int j = 0; j < this.imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.listView1.Items.Add(item);
}
}
推荐答案
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(directoryName);
或
or
using System.IO;
//...
DirectoryInfo dir = new DirectoryInfo(directoryName);
或
or
using DirectoryInfo = System.IO.DirectoryInfo; //alias
//...
DirectoryInfo dir = new DirectoryInfo(directoryName);
这篇关于如何使用directoryinfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!