Correct way to write etc/hosts

  • Thread starter Thread starter Haxan
  • Start date Start date
H

Haxan

Hi,
I am looking for a way to write etc/hosts file.
Is there any APIS for search/delete/insert/update for entries ? or behave
hosts as a normal file ?

thanks in advance
 
Hi

| Hi,
| I am looking for a way to write etc/hosts file.
| Is there any APIS for search/delete/insert/update for entries ? or behave
| hosts as a normal file ?

Not that I know of, why do u want to do this anyway?
 
I am looking for a way to write etc/hosts file.

It's a text file. Pretty much every language under the sun has
capabilities to read/write a text file a line at a time. Not rocket
science, but might be a little tedious.

Nathan Mates
 
I am looking for a way to write etc/hosts file.
It's a text file. Pretty much every language under the sun has
capabilities to read/write a text file a line at a time. Not rocket
science, but might be a little tedious.

..NET has easy to use APIs like the TextWriter class.
Just be sure that you have the appropriate permissions.
I think you have to run with admin privileges.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Haxan said:
Hi,
I am looking for a way to write etc/hosts file.
Is there any APIS for search/delete/insert/update for entries ? or behave
hosts as a normal file ?

system32/drivers/etc/hosts is a normal text file, the only additional thing
you need to worry about is that the DNS client service might cache the
contents. "ipconfig /flushdns" is the command to expire the cache
immediately, I don't know the equivalent API.
 
Back
Top