This is probably simple, but a quick search didn't produce anything.

How do I programmatically set a file to be read only?