Hi!
Here is what I'm trying to do:
I have created a UserControl named PictureView. It holds all the images
in one directory in the Bitmap[] images variable.
The selected image is displayed in the PictureBox control.
Here is how it works.
1. I get all the filenames of the images in the specified directory
2. I open the Bitmaps (I used Bitmap.FromFile but found out that it locks
the files so I
open them using FileStream).
The user can not click "left" or "right" buttons and view the images.
The images are "bound" to an item. So if the code of an item is "1" it's
images are stored
in : (baseDir)\images\1...
The problem comes when the user presses the "delete" button. Here is what I
do then:
1. I close the file streams I dispose of ALL the images
2. I put each of the images = null;
3. I put the images[] = null;
4. I dispose of the image in the PictureBox
And I call the Garbage collector just in case...
Then I try to delete the file. Here are the errors that I get:
"Cannot delete file (correct path) because It's being used by another
process"
or
"Cannot ......... Access denied"
If I go and look at the properties of the directory I see that it is set to
"read-only" and it seems
that windows (or .net fw) is manually changing this to read-only every time
I try to add another picture
or everytime I close and re-open the application.
This is really driving me crazy :(
Help? Anyone?