I use the following line of code to open Image from a file:
pictureBox1.Image = Image.FromFile("test.png");
I expect it to lock the file, load the image into memory, set pictureBox1.Image to a copy in memory, and release the lock. In fact, the lock will not disappear until I Dispose() in Image in memory. I canβt release the file lock on the hard drive, which I no longer use, until I get rid of the file in memory that I use.
The Microsoft site mentions it in an article in C #, but their solution is written on a visual basis, which is useless to me.
In short: I want to set pictureBox1.Image to the image saved in "test.png" , then allow the user to edit or delete "test.png" or something else.
c # locking image winforms
Eagle-Eye Jul 04 2018-11-11T00: 00Z
source share