在form1中,我有一个计时器滴答事件,我保存屏幕截图到硬盘:
private void timer1_Tick(object sender, EventArgs e)
{
count++;
sc.CaptureScreenToFile(mainDirectory + count.ToString("D6") + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
sc.CaptureScreen();
label2.Text = count.ToString();
if (count == 1)
{
label4.Text = string.Format("{0:N2} KB", GetFileSizeOnDisk(mainDirectory + "000001.jpg").ToString());
label4.Visible = true;
}
}
DisplayImages();
每次新截图保存到硬盘后,我想在pictureBox1中显示此图像。然后再下一个……定时器间隔设置为1000ms。因此,pictureBox1中的截图应该每秒钟更改一次。
private void DisplayImages()
{
}
我怎么能得到每秒钟硬盘上的文件,并显示在pictureBox ?并且要确保文件没有被使用,如果它是重要的。
例如硬盘上的第一个文件是:000001.jpg然后000002.jpg等等
private void timer1_Tick(object sender, EventArgs e)
{
count++;
string fileName = mainDirectory + count.ToString("D6") + ".jpg";
sc.CaptureScreenToFile(fileName , System.Drawing.Imaging.ImageFormat.Jpeg);
sc.CaptureScreen();
label2.Text = count.ToString();
if (count == 1)
{
label4.Text = string.Format("{0:N2} KB", GetFileSizeOnDisk(fileName).ToString());
label4.Visible = true;
}
pictureBox1.ImageLocation = fileName;
}