How to set apple icon image (xxx.icns) to file or folder

filefoldersicon

There is already a related question talking about setting a png image to file or foler as icon (
How can I change a file or folder icon using the Terminal), but what if my image is an icns?

I know pngs may be extracted from an icns, then follow the solution above. But icns has an advantage that it could fit different sizes.
So how could I set apple icon image (xxx.icns) to file or folder?

Best Answer

Right click the file and click "Get Info" (or press Cmd+I on the file). Drag the desired icon onto the current icon and it will replace the existing one.