ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Cannot delete files after FillFromDirectory
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Tod

9 Posts

Posted - Feb 23 2012 :  12:15:40  Show Profile  Reply
I am using the FillFromDirectory function to populate thumbnails. I then have a Popup menu with a delete option. I call DeleteSelectedImages, and all the selected thumbs are removed. This works good. However, the actual files are still locked and cannot be deleted. Is there a work around for this or has it been fixed in 4.1?

I am using 4.01 (requested an update for 4.1)

Thanks

xequte

39053 Posts

Posted - Feb 23 2012 :  12:22:50  Show Profile  Reply
Hi

Are these just image files? What version of windows are you using?

Can you confirm that ImageEn is locking them by:

1. Deleting some random files from a folder
2. Use FillFromDirectory on that folder
3. Delete some more random files from that folder
4. Close the test app
5. Delete some more random files from that folder


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Tod

9 Posts

Posted - Feb 23 2012 :  12:54:24  Show Profile  Reply
yea, they are all bitmaps.

I believe I have found a solution.

j:=imgView.MultiSelectedImagesCount;
i:=0;
sl:=TStringList.Create;
while (i<j) do begin
    s:=imgView.ImageFileName[imgView.MultiSelectedImages[0]];
    sl.Add(s);
    inc(i);
    imgView.ReleaseBitmap(imgView.MultiSelectedImages[0]);
    imgView.DeleteImage(imgView.MultiSelectedImages[0]);
    j:=imgView.MultiSelectedImagesCount;
end;
for i:=0 to sl.Count-1 do DeleteFile(sl[i]);
sl.Free;


The imgView.ReleaseBitmap(imgView.MultiSelectedImages[0]); line is the key.
Go to Top of Page

fab

1310 Posts

Posted - Feb 23 2012 :  13:37:54  Show Profile  Reply
TImageEnMView doesn't leave open (hence locked) source file. It caches image buffers on disk, but leave original file closed.
Actually I cannot explain because ReleaseBitmap help you: it should not help, because it just releases a bitmap retrieved using GetBitmap or GetTIEBitmap.
However I tested FillFromDirectory, followed by a DeleteSelectedImages and DeleteFile, without problems.
Go to Top of Page

Tod

9 Posts

Posted - Feb 23 2012 :  14:56:48  Show Profile  Reply
Since upgrading to 4.1, the problem has vanished using DeleteSelectedImages.

One thing of note you may want to investigate

If using a loop similar to what I have above in 4.1, the function
imgView.MultiSelectedImagesCount; returns improper values after deleting 1 image. i.e. Enter loop with 3 selected images. Call DeleteImage, then look at the value returned by imgView.MultiSelectedImagesCount; It should be 2, but instead returns 1. In version 4.01, it returned a proper value.



Go to Top of Page

fab

1310 Posts

Posted - Feb 24 2012 :  09:58:48  Show Profile  Reply
This because DeleteImage() empties current selection before actually delete the specified image. It returns 1 because only one image remains selected after DeleteImage(). This is the same behavior of old versions (3.x), so you should have the same result with 4.0.1.
To remove selected images you should call DeleteSelectedImages().
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: