hello !
i am working on a simple application that can block the sites ,after searching i found that if i add name of the site in c:\windows\system32\drivers\etc\hosts then i can block those sites , for this i want to open this hosts file in my textbox with administrator rights , so that it can save changes. how i can do this ? do i have to run my application with administrator rights or i can just open hosts file in my textbox with administrator rights ?

regards

Recommended Answers

All 5 Replies

Why you want to open in textbox? Try reading in moemory and add the site..

can you please explain it little bit , i cant get your point.

Using IO read the file in memory.. And add the line to text file using IO.File.Write and save the file..

If you start Notepad as administrator and open the host-file you can edit and save it. No application needed.

thanks both of you for your help . i just run my application as administrator and just make changes in my file ,

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.