0
每次上传者裁剪图像时我都会保存一个新图像,并且我想检查每个新图像是否存在。我有这样的代码:检查目录中是否存在多个文件
private void pictureBox5_MouseUp(object sender, MouseEventArgs e)
{
Selecting = false;
// Copy the selected area.
SelectedArea = GetSelectedArea(pictureBox5.Image, Color.Transparent, Points);
SelectedArea.Save(@"C:\Users\User\Desktop\Gallery\image1cropped.png", ImageFormat.Png);
}
我希望它像保存image2cropped,image3cropped ..并检查它是否存在像
if(File.Exists(@"C:\Users\User\Desktop\Gallery\image1cropped.png", ImageFormat.Png);
我想它来检查像image2cropped,image3cropped ..等等。 想法?
是的解救它的东西。但我想检查它们是否存在是相同的算法? –
没关系我解决了它。 (@“C:\ Users \ User \ Desktop \ Gallery \ image”+ NumberOfClick.ToString()+“cropped.png”,ImageFormat.Png);这是我的最终代码: SelectedArea.Save string filename = @“C:\ Users \ User \ Desktop \ Gallery \ image”+ NumberOfClick.ToString()+“cropped.png”; if(File.Exists(filename)) {button1.Visible = true; pictureBox5.Visible = false; } –
是否要在保存之前检查它是否覆盖它或保存后检查它是否保存完好? – Elloco