Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Write in textfile & recognize new lines from RichTextBox

Hey,
i want my program to write text from a RichTextBox to the hosts.-file to block some sites. My problem is now that my code doesn't recognize a new line I have made in the RichTextBox. It writes the text in the hosts.-file like this:
"127.0.0.1 www.virustotal.com127.0.0.1 www.eset.com127.0.0.1 www.avast.com"

Code
Dim Hosts As String = Environment.SystemDirectory & "\drivers\etc\hosts"
                        Dim sr As New StreamReader(Hosts)
                    Dim input As String = sr.ReadToEnd()
                        sr.Close()
                        Dim output As String = input & vbNewLine & blockedwww
                    output.Replace(vbLf, vbNewLine)
                        Dim sw As New StreamWriter(Hosts)
                        sw.Write(output)
                        sw.Close()

blockedwww = RichTextBox.Text
If you know how I can fix that, I really appreciate your help!

Best regards
Read this: https://www.dotnetperls.com/for-vbnet
Should be fairly easy to understand how to use a for next statement.
You are using the unix format of newline (lf), windows has crlf's, to be safe use Environment.Newline


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by CryptAug 18, 2020 05:32 PM 2 158 Aug 18, 2020 05:32 PM
Last Post: Crypt
[.NET] by PerileosMay 11, 2020 09:21 PM 24 603 May 11, 2020 09:21 PM
Last Post: Alien
[.NET] by MalwareMopAug 7, 2019 02:18 PM 0 141 Aug 7, 2019 02:18 PM
Last Post: MalwareMop