public static void deleteUnusedFiles(File residentDir, Set<String> fileNames)
    {
    	int count = 0;
    
    	if (residentDir.isDirectory())
    	{
    		File[] children = residentDir.listFiles();
    		if (children != null)
    		{
    			for (File child : children)
    			{
    				try
    				{
    					String filename = child.getName();
    					if (child.isFile())
    					{
    						if (filename.contains(".txt"))
    							filename = filename.split("\\.txt")[0];
        
    						// Delete the file if there is no matching resident.
    						if (!fileNames.contains(filename.toLowerCase()))
    						{
    							deleteFile(child);
    							count ++;
    						}
    					}

    				}
    				catch (Exception e)
    				{
    					// Ignore file
    				}
    			}
        
    			if (count > 0)
    			{
        			System.out.println(String.format("[ccSpawners] Deleted %d old files.", count));
    			}
    		}
    	}
	}