access issue (file is in use)
Posted: Mon Nov 29, 2010 6:52 am
I have an application that displays an image in the viewer control for the user to inspect, and then after making some keystrokes, the image is intended to be renamed.
The problem is that often / most of the time the rename function fails, an IOException thrown because the source file is in use.
I have tried:
- Dispose the image [viewer.Images.Item(0).Dispose()]
- Dispose of the whole thing [viewer.Images.ClearAndDisposeItems()[
- Both of the above
- All of the above with a forced GC.Collect / GC.WaitForPendingFinalizers
- All of that, plus some misc. sleep commands
- All of that, plus viewer.Dispose.
Any ideas? This is a real potential problem - how do I really, totally, completely close an image and be sure that I can access that file consistently?
The problem is that often / most of the time the rename function fails, an IOException thrown because the source file is in use.
I have tried:
- Dispose the image [viewer.Images.Item(0).Dispose()]
- Dispose of the whole thing [viewer.Images.ClearAndDisposeItems()[
- Both of the above
- All of the above with a forced GC.Collect / GC.WaitForPendingFinalizers
- All of that, plus some misc. sleep commands
- All of that, plus viewer.Dispose.
Any ideas? This is a real potential problem - how do I really, totally, completely close an image and be sure that I can access that file consistently?