C# 在c中不使用opendialog从文件夹加载图像文件#
我将视频转换为位图图像序列并另存为 pictureBox1.Image.Save(@“D:\pic\”+name+“.bmp”,ImageFormat.bmp) 驱动器D文件夹中的图像名称另存为(0001,0002,0003,……0200) 现在我有序列的位图我需要加载所有的图像文件,除了第一个图像,我不能 使用opendialog,因为它是199图像,我需要按顺序使用,我怎样才能在c#中做到这一点 例如: //加载第二个图像 //动手术 //加载第三个图像 //动手术 . . . . //加载最后一个图像(199) //进行一些操作尝试以下操作:C# 在c中不使用opendialog从文件夹加载图像文件#,c#,image,bitmap,image-uploading,C#,Image,Bitmap,Image Uploading,我将视频转换为位图图像序列并另存为 pictureBox1.Image.Save(@“D:\pic\”+name+“.bmp”,ImageFormat.bmp) 驱动器D文件夹中的图像名称另存为(0001,0002,0003,……0200) 现在我有序列的位图我需要加载所有的图像文件,除了第一个图像,我不能 使用opendialog,因为它是199图像,我需要按顺序使用,我怎样才能在c#中做到这一点 例如: //加载第二个图像 //动手术 //加载第三个图像 //动手术 . . . . //加载
public void Load(string path)
{
foreach string s in path {
using(Stream bmpStrm= System.IO.File.Open(s, System.IO.FileMode.Open ))
{
Image img = Image.FromStream(bmpStrm);
b=new Bitmap(img);
DoYourThang(b)
}
}
你可以做:
参考Linq:
using System.Linq;
FileInfo[] files = new System.IO.DirectoryInfo().GetFiles(@"D:\pic\*.bmp").OrderBy(file => file.Name).Skip(1).ToArray()
DirectoryInfo().GetFiles(@“D:\pic\*.bmp”)将返回一个包含文件所有信息的FileInfo数组。这在System.IO命名空间中。如果您将其与LinQ、System.LinQ结合使用,那么您可以按名称排序,跳过第一个条目,并将其余条目作为FileInfo[]数组返回。
DirectoryInfo.GetFiles(“*.bmp”)
请我需要除第一个图像以外的所有图像,然后用于(I=1;iOr更好,使用一点LinQ DirectoryInfo.GetFiles(“*.bmp”).OrderBy(file=>file.name).Skip(1.ToArray()@Steve,你能解释一下吗more@kokiUps!字符串,对不起我的坏:S