Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

vb.net streamwriter.

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 12-14-05, 06:15 PM Thread Starter   #1
Crash893
"The man in black fled across the desert, and the gunslinger followed."
Senior Member

 
Crash893's Avatar 

Join Date: Mar 2001
Location: 22033

10 Year Badge
 
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.'
Crash893 is offline   QUOTE Thanks
Old 12-14-05, 06:17 PM   #2
Tacoman667
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
Tacoman667 is offline   QUOTE Thanks
Old 12-14-05, 06:31 PM   #3
Tacoman667
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
Tacoman667 is offline   QUOTE Thanks
Old 12-14-05, 09:24 PM Thread Starter   #4
Crash893
"The man in black fled across the desert, and the gunslinger followed."
Senior Member

 
Crash893's Avatar 

Join Date: Mar 2001
Location: 22033

10 Year Badge
 
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.'
Crash893 is offline   QUOTE Thanks
Old 12-15-05, 05:25 AM   #5
Tacoman667
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
Tacoman667 is offline   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 02:37 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?