My place got infested badly with fruit flies one time while I was in college. We were doing an experiment in a genetics lab, so were growing fruit flies for that. Being a bit soft-hearted, I just couldn't bring myself to kill the fruit flies at the end of the experiment, so I took many of them home and let them go outside in the garden. But some got into the house somehow and I had a really hard time getting rid of them. One thing I learned was if you have open trashcans in the kitchen, better empty them daily while the problem persists. Those flies will sometimes find things they like in what food scraps you throw away.