Answer the question
In order to leave comments, you need to log in
The process cannot access the xxx.png file when I delete an image. How to solve the problem?
Shorter. I open 10 pictures through open file dialog. Through foreach, the photos are individually edited and saved to a different folder. When it comes time to delete old photos, this error pops up.
Here is the code.
private void zatemnit ()
{
Bitmap img1; //Bitmap для открываемого изображения
OpenFileDialog OpDi = new OpenFileDialog { Multiselect = true };
//создание диалогового окна для выбора файла
OpDi.Filter = "Файлы изображений (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png";
if (OpDi.ShowDialog() == DialogResult.OK)
{
string[] result = OpDi.FileNames;
int count = result.Length;
progressBar1.Maximum = count;
count = 0;
string names = "";
//zatemneniye
foreach (String file in OpDi.FileNames)
{
//секретный код затемнения image
string fileName = "mem" + p + ".png";
//сохранение файла на пк
img1.Save(@"images//" + fileName);
names = null;
progressBar1.PerformStep();
MessageBox.Show(file);
}<--заканчивается форич
}
OpDi.Dispose();
}
Answer the question
In order to leave comments, you need to log in
Ok, I added
string fileName = "mem" + p + ".png";
//сохранение файла на пк
img1.Save(@"images//" + fileName);
names = null;
progressBar1.PerformStep();
MessageBox.Show(file);
img1.Dispose(); ,<=== вот это, вроде работает
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question