Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
'The process cannot access the file ... ' error
Rank: Member
Groups: Guest
Joined: 4/15/2007(UTC) Posts: 25
|
Dear sirs, in our vb.net application, we have 2 forms. The first form has a button and when pressed, it opens the second form. The second form is like an image viewer, it has thumbnails(using a treelist control) and one bitmapViewer1 control, on which we show images. The images loaded in the second form, are located in a specific folder. What we want to do is to delete this folder(and all files included) when second form closes, but the problem is that we get this error: "The process cannot access the file 'C:\fld\2.jpg' because it is being used by another process." but deletes the other 2 files and does NOT delete the folder. Suppose we see 3 images on the second form, the c:\fld folder has 1.jpg, 2.jpg and 3.jpg. We use this: Code:Private Sub secondForm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
ImageList1.Images.Clear()
ImageList1.Dispose()
ImageList1 = Nothing
treelist1.Items.Clear()
treelist1.Dispose()
treelist1= Nothing
bitmapViewer1.Bitmap.Unlock() 'Just in case it is locked, but we never use .Lock method
bitmapViewer1.Bitmap.Dispose()
bitmapViewer1.Bitmap = Nothing
bitmapViewer1.Dispose()
bitmapViewer1 = Nothing
bitmapViewer1.Bitmap.Unlock()
IO.Directory.Delete("C:\fld\", True) 'Here comes the error 'process cannot access the file......
End Sub
Few times it deletes all files and the folder, but most times it does not, it raises the error shown above. We do not make any use of .Lock method. What is wrong with it ? How can we make it possible to delete the folder and both 3 files when form closed? Of course we never open or access any file on the folder!!! Thanks in advance, firamax Edited by user Monday, December 17, 2007 12:18:56 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
Hello, Please, review your source code and check whether you close all opened readers and writers (in case if you use them) before you close the form. |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 4/15/2007(UTC) Posts: 25
|
Well, i use this code to the thumbnails : Code:
For Each frame As TiffFrame In tiffReader
Dim thumbnailBitmap As New Aurigma.GraphicsMill.Bitmap
frame.GetThumbnail(thumbnailBitmap, thumbnailSizeWidth, thumbnailSizeHeight)
Dim thumbnail As Aurigma.GraphicsMill.Bitmap = CreateThumbnail(thumbnailBitmap)
thumbnailsView.Items.Add("Page " & (number + 1).ToString(), number)
thumbnailsView.Items.Item(number).Tag = arrayTagData
imageList.Images.Add(thumbnail.ToGdiplusBitmap())
number += 1
frame.Dispose()
thumbnail.Dispose()
Exit For ' I need only the 1st page in case of multi page tiff
Next
But i never close the reader. Can you please give a sample on how to close this tiffReader ? firamax Edited by user Monday, December 17, 2007 12:19:38 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Guest
Joined: 4/15/2007(UTC) Posts: 25
|
Ok, i found it. I needed to use the .Close() method for each reader i opened. Dmitry, thanks a lot for accurate understanding/answer of my problem !!! firamax
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
|
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
'The process cannot access the file ... ' error
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.