标签:led his image pat detail fromfile efi files new
1、遍历一个目录下的全部目录,要用到System.IO.DirectoryInfo 类的GetDirectories方法:
DirectoryInfo dir = new DirectoryInfo(@"c:\");
foreach(DirectoryInfo dChild in dir.GetDirectories("*"))
{//如果用GetDirectories("ab*"),那么全部以ab开头的目录会被显示
Response.Write(dChild.Name + "<BR>");//打印目录名
Response.Write(dChild.FullName + "<BR>");//打印路径和目录名
}
2、遍历一个目录下的全部文件,要用到System.IO.DirectoryInfo 类的GetFiles方法:
DirectoryInfo dir = new DirectoryInfo(@"c:\");
foreach(FileInfo dChild in dir.GetFiles("*"))
{//如果用GetFiles("*.txt"),那么全部txt文件会被显示
Response.Write(dChild.Name + "<BR>");//打印文件名
Response.Write(dChild.FullName + "<BR>");//打印路径和文件名
}
3、选择单个文件
OpenFileDialog openFileDialogTemp = new OpenFileDialog();
DialogResult dr = openFileDialogTemp.ShowDialog();
if (dr == DialogResult.OK)
{
imagepath = openFileDialogTemp.FileName;//图片完整路径
imagename = openFileDialogTemp.SafeFileName;//图片文件名称
image = Image.FromFile(imagepath);
pictureBox1.BackgroundImage = image;
this.txtPath.Text = imagepath;
}
来源:http://blog.csdn.net/ldl22847/article/details/7763018
标签:led his image pat detail fromfile efi files new
原文地址:http://www.cnblogs.com/wushijie/p/7136038.html