How do you programmatically add a new entry to the Hosts file in Mac?
For example on Windows, you just open up a StreamWriter and output to the Hosts file. How do you do this on a Mac?
How do you programmatically add a new entry to the Hosts file in Mac?
For example on Windows, you just open up a StreamWriter and output to the Hosts file. How do you do this on a Mac?
The hosts file is at
/etc/hosts
so you can add to it by just writing to it. But you should never delete the first few lines corresponding to the local host. Also, it's only accessible with the root privilege.