我正在尝试在制作屏幕截图后删除文件。代码如下:
private static void makeSc()
{
DateTime d = DateTime.Now;
string currentDT = String.Format("{0:yyyy-MM-dd-hhmmsstt}", d);
string scrFilename = currentDT+".jpg";
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save(scrFilename, ImageFormat.Jpeg);
//delete file
bmpScreenShot.Dispose();
Thread.Sleep(20);
File.Delete(scrFilename);
}
似乎也没有Dispose()
延迟。有什么想法吗?