Answer the question
In order to leave comments, you need to log in
C# After loading a picture in picturebox, delete it from disk?
Loading an image in a picturebox. Then I want to remove it from the disk. But it throws an exception that the file is busy. Already before removal did so: picturebox1.Image = null;
- does not help. How to be? Thank you.
I load like this:picturebox1.load(путь_к_картинке);
Answer the question
In order to leave comments, you need to log in
It is better to work with files through FileStream in order to fully control the whole process:
string filePath = "123.jpg";
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Inheritable))
{
pictureBox1.Image = Image.FromStream(file);
}
File.Delete(filePath);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question