Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to block any url.... I can not understand how to proceed ? iam not asking about only internet explorer..it can be any browser...e.g. mozila,google chrome or safari etc.. can any one discuss about this topic or any kind hints ...
Posted
Comments
Sergey Alexandrovich Kryukov 5-Dec-12 1:16am    
What can it possibly mean? Block from what, who? Why?! Right now, it does not seem to make any sense at all.
--SA

1 solution

try this.
C#
private void button1_Click(object sender, EventArgs e)
        {
            String path = @"C:\Windows\System32\drivers\etc\hosts";
            StreamWriter sw = new StreamWriter(path, true);
            String sitetoblock = "\n 127.0.0.1 Your_url_for_blocking";
            sw.Write(sitetoblock);
            sw.Close();           
        }
 
Share this answer
 
Comments
krushna chandra jena 5-Dec-12 5:44am    
in windows 7 the above code does not working. The hosts file does not allow to modify itself.......Please provide another solution. This may be working in windows xp but only for internet explorer..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900