I just moved into my apartment a couple months ago, and from day 1 I've had flies(there were only a couple when I came in and none anytime I checked the place out prior.)
The problem worsened over time - the air conditioning was running when I came in and had been running for a few weeks while I got the credentials I needed to be able to shut it off.
When I shut it off the flies disappeared within a couple of days, and when I turned it on again during a heat spike a couple days later they came back.
Its pretty clear that the flies are pooling whatever moisture is in the HVAC system.
I called/emailed apt maintenence for help, but they said they aren't going to be able send someone