hibbidiji
asked on
Updating listbox when file is deleted
I have a listbox (specifically a sunisoft file list box) that shows the files in a dir. In my testing I've found that when I delete the files in the dir its pointed at using explorer, the list doesnt update
Should I use a timer? that seems like an imperfect solution at best. Any suggestions?
Should I use a timer? that seems like an imperfect solution at best. Any suggestions?
I wonder if there is some sort of a windows message you could be polling for.
If you have 2 explorer windows open pointing to the same directory, and you delete a file from one, it automatically refreshes the other.
There might be a windows call somewhere here you could take advantage of.
If you have 2 explorer windows open pointing to the same directory, and you delete a file from one, it automatically refreshes the other.
There might be a windows call somewhere here you could take advantage of.
ASKER
Thats what I'm hoping for (though I wouldnt know how to poll for the message even if we knew what it was) :)
he he .. unfortunately neither do I, but hopefully my suggestion might be seen by someone who remembers how to do it and can give you the code.
I wish I knew more API stuff, but my knowledge in this area is pretty much non existant. Probably because I have no use for it these days.
I wish I knew more API stuff, but my knowledge in this area is pretty much non existant. Probably because I have no use for it these days.
I found one possible link that might help
https://www.experts-exchange.com/questions/11428379/filelistbox-refresh.html
also do a search for "windows explorer refresh" here at EE. Might be a few more links that can help
https://www.experts-exchange.com/questions/11428379/filelistbox-refresh.html
also do a search for "windows explorer refresh" here at EE. Might be a few more links that can help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry ZhaawZ, I didn't see your comments when I open the questions
I load files into my IDE but of course some idiot might edit or delete them outside. To monitor this, like Delphi does, I use a directory monitor. This sends me an event when anything changes in any of the directories from which I have loaded files. I'm currently using TDirMon (see Torry's pages) from Juan Carlos Molinos, which I've had to modify. There is another from Francois Piette which I have not yet tried out.
One problem I've found is that the components are very heavy, starting threads to pick up Windows events, but it does work.
I popup a message box saying that the file has changed and whether they want a reload. In your app, I'd popup a box warning of the change and then simply reload the list box.
HTH
One problem I've found is that the components are very heavy, starting threads to pick up Windows events, but it does work.
I popup a message box saying that the file has changed and whether they want a reload. In your app, I'd popup a box warning of the change and then simply reload the list box.
HTH
check this thread
https://www.experts-exchange.com/questions/21226302/Bugfix-Or-a-challenge-Find-the-bugs.html
there is a link to a unit that implements exactly what you need, something like a Directory Watcher, but without using a Timer
https://www.experts-exchange.com/questions/21226302/Bugfix-Or-a-challenge-Find-the-bugs.html
there is a link to a unit that implements exactly what you need, something like a Directory Watcher, but without using a Timer
ASKER
Thanks guys. Excellent answer. worked first time
Because your program doesnt actually delete the file itself, you will need to monitor it on a timer event I would think.