I've used this for various infestations, it works on Fleas, regular flies, fruit flies, etc.
It also kills the larvae, keep in mind flies are attracted to rotting things like spoiled meat, dead rodents. Make sure you also get rid of what is attracting them.
I used a product called Siphotrol
It's a fogger but it also forces eggs to prematurely hatch and die, this ends the cycle and they are gone for good. Just follow the directions on the can and they will be gone for good.
I used it for a fruit fly infestation, worked the first time and I highly recommend it.