I had an infestation of what I thought were fruit flies -- tiny black flies that swarmed around the guinea pig cage and at night, on the ceiling. They weren't fruit flies, though, as they were not at all attracted to sweet things in traps I put out.
I tried everything I could think of -- keeping the cage scrupulously clean, hanging fly tape, vacuuming them off the ceiling, cleaning the drains, whatever. Nothing worked. I finally bought a bug zapper similar to this: (broken link removed)
It makes a popping noise when the bug hits it, but the pigs got used to that really quickly. It took several days to get rid of them, but it finally worked.