Since there is no method to verify the trustworthiness of shared files in P2P systems, malicious peers can spread untrustworthy files to the system. In order to prevent untrustworthy files from spreading, we propose an effective reputation management system using peer reputation and file reputation together in DHT-based structured P2P networks. Simulation results show that the proposed reputation system works better in preventing untrustworthy files from spreading than existing systems even in cases of allowing malicious peers to change their identities.