PB-deleted file still appears in Windows Explorer

Just starting out? Need help? Post your questions and find answers here.
PB2004
User
User
Posts: 33
Joined: Sat Aug 11, 2007 6:16 pm
Location: Frisco, US

PB-deleted file still appears in Windows Explorer

Post by PB2004 »

From PureBasic, I delete a file but it still appears afterward in Windows Explorer. If I click on it, I get the message "Could not find this item. This is no longer located...." If, in Windows Explorer, I move off the directory and then back in, the file is no longer listed.

Does someone know some trick to fix this ghosting?

Windows 7, PB ver. 5.50 x64

Thanks
User avatar
skywalk
Addict
Addict
Posts: 4301
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB-deleted file still appears in Windows Explorer

Post by skywalk »

This happens with several apps and Windows Explorer AutoRefresh disabled or not running.
Just hit [F5] to Refresh. Some answers on web.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Mijikai
Addict
Addict
Posts: 1523
Joined: Sun Sep 11, 2016 2:17 pm

Re: PB-deleted file still appears in Windows Explorer

Post by Mijikai »

U could call InvalidateRect_(0,0,0) iirc
after the file is deleted to trigger a refresh.
PB2004
User
User
Posts: 33
Joined: Sat Aug 11, 2007 6:16 pm
Location: Frisco, US

Re: PB-deleted file still appears in Windows Explorer

Post by PB2004 »

Thanks both! The reason for this is that I really don't want the user to be alarmed by a ghosted, intermediate and temporary file that is part of the app processing. Triggering a refresh of Explorer would be great, but is at present beyond my noobile abilities (having searched for a couple of hours).

I suppose i would need a way to detect if Explorer was open (if not open, no problem), get its window handle (hwnd ?), and then use Mijikai's InvalidateRect_ approach.

If someone has some tight code for this that can handle win7 thru 10 that would be amazing.
firace
Addict
Addict
Posts: 947
Joined: Wed Nov 09, 2011 8:58 am

Re: PB-deleted file still appears in Windows Explorer

Post by firace »

This should work (courtesy of Rebon from the German forum):

Code: Select all

Procedure ReDe()
   hWnd = FindWindow_("Explorer.EXE", #Null)
   InvalidateRect_(hWnd, #Null, 1)
   UpdateWindow_(hWnd)
EndProcedure

ReDe()
PB2004
User
User
Posts: 33
Joined: Sat Aug 11, 2007 6:16 pm
Location: Frisco, US

Re: PB-deleted file still appears in Windows Explorer

Post by PB2004 »

Beautiful. EXACTLY what the noob needed. Thank you so much!
Post Reply