Results 1 to 5 of 5
  1. #1
    "The man in black fled across the desert, and the gunslinger followed."
    Senior Member
    Crash893's Avatar
    10 Year Badge
    Join Date
    Mar 2001
    Location
    22033

    vb.net streamwriter.

    im makeing a small app to help me add entries to the hosts file in windows

    i got most of it down except

    when i
    Code:
        Dim hostwriter As New StreamWriter("c:\hosts.txt")
    
                'Write line to hosts file
                hostwriter.WriteLine(vbNewLine & "127.0.0.1 ".PadRight(10) & TextBox1.Text.PadRight(5) & " #Blocked by Robert Barbrow")
                hostwriter.Close()
    i know hosts insnt in c:\ its just a test file till i get it working


    i get one line in the hosts file then it will over write that same line
    how do i get streamwriter to read the lentgh of the file then increment it down one to add my entire?
    My Prime95 stats Huzza
    1004.793 Years total
    Noli turbare circulos meos!
    i'm moving to Theory, Everything works there
    ' I want to be the unwobbling pivot at the center of an ever-revolving universe; I want to be still.'

  2. #2
    Member
    Join Date
    Apr 2001
    Location
    Kingwood, TX
    Dim hostwriter As New System.IO.StreamWriter("c:\hosts.txt", True)


    The true arguement makes it append to the end of the file.
    Who was the first person to look at a cow and say, "I think I'll squeeze these dangly things here, and drink whatever comes out?"

    Who was the first person to say "See that chicken there....I'm gonna eat the next thing that comes out of it's butt."



    A64 3200+
    DFI LanParty UT NF3 250GB
    1024meg 2x512meg Kingston HyperX
    ATI 9800 PRO 128meg
    2x80gig Maxtor SATA RAID0

  3. #3
    Member
    Join Date
    Apr 2001
    Location
    Kingwood, TX
    If you wanted to put the new entry in the beginning of the file, you should do this:

    Dim tString as string
    Dim hostwriter As New System.IO.StreamWriter("c:\hosts.txt")

    tstring = hostwriter.readall
    hostwriter = New System.IO.StreamWriter("c:\hosts.txt")
    hostwriter.WriteLine(tstring & vbNewLine & "127.0.0.1 ".PadRight(10) & TextBox1.Text.PadRight(5) & " #Blocked by Robert Barbrow")
    hostwriter.Close()
    Who was the first person to look at a cow and say, "I think I'll squeeze these dangly things here, and drink whatever comes out?"

    Who was the first person to say "See that chicken there....I'm gonna eat the next thing that comes out of it's butt."



    A64 3200+
    DFI LanParty UT NF3 250GB
    1024meg 2x512meg Kingston HyperX
    ATI 9800 PRO 128meg
    2x80gig Maxtor SATA RAID0

  4. #4
    "The man in black fled across the desert, and the gunslinger followed."
    Senior Member
    Crash893's Avatar
    10 Year Badge
    Join Date
    Mar 2001
    Location
    22033
    thanks for your quick response

    that extra ,true at the end works perfect
    My Prime95 stats Huzza
    1004.793 Years total
    Noli turbare circulos meos!
    i'm moving to Theory, Everything works there
    ' I want to be the unwobbling pivot at the center of an ever-revolving universe; I want to be still.'

  5. #5
    Member
    Join Date
    Apr 2001
    Location
    Kingwood, TX
    Happy to help.
    Who was the first person to look at a cow and say, "I think I'll squeeze these dangly things here, and drink whatever comes out?"

    Who was the first person to say "See that chicken there....I'm gonna eat the next thing that comes out of it's butt."



    A64 3200+
    DFI LanParty UT NF3 250GB
    1024meg 2x512meg Kingston HyperX
    ATI 9800 PRO 128meg
    2x80gig Maxtor SATA RAID0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •