110,538
社区成员
发帖
与我相关
我的任务
分享
public Image GetRandomImage()
{
Random rand = new Random((int)DateTime.Now.Ticks);
string[] pictures = Directory.GetFiles("C:\\Images");
Image img = null;
if (pictures.Length > 0)
{
int index = Math.abs(rand.Next()) % pictures.Length;
img = Image.FromFile(pictures[index]);
}
return img;
}