Writing to Text File

Posts 1–11 of 11 · Page 1 of 1
Writing to Text File
Right now i got this code
creds to NextGen1

Code:
 Dim path As String = "D:\EmailList.txt"
        Dim stream As New FileStream(path, FileMode.Append, FileAccess.Write)
        Dim write As New StreamWriter(stream)
        write.WriteLine(Email.Text & "@yahoo.ca" & ",")
        write.Close()
        MessageBox.Show("Saved @ " & path, "File Saved", MessageBoxButtons.OK, MessageBoxIcon******rmation)
but it writes on a new line
Code:
hkjhkjhkjhkjh@yahoo.ca,
kjhkjhkjkjhkj@yahoo.ca,
How do you make it so that it continues with the first line?
Not completely sure, but just guessing I am pretty sure "WriteLine" goes to next line so maybe check for a function that is just "Write".
found it. instead of writeline. it is write
Coder Never is right, use Write.Write not Write.WriteLine if you want it to stay in the same line.
Ok i quick question.

Is there a function for reading line in textfile and comparing it to a line in a textbox.

So if line in textfile = line in textbox
MsgBox = "The email is already saved."
try something like this

Code:
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:/File Location")
if filereader.contains(textbox1.text) then
msgbox("Contains Text")
else 
'doesn't
end if
or more for you..

Code:
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(path)
if filereader.contains(textbox1.text) then
msgbox("Contains E-mail")
else 
msgbox("Does not Contain E-mail")
end if
You are on a roll , beat me twice in 10 mins

Granted that's MSDN Basics 101 and readily available code, still quicker


Lol Well I added to it =D , hey nextgen1 add me on msn?

Code:
Never.Easyasace@live.com
wow code never. nice it worked excellent.
Not to go off topic but I don't get whats up with people calling me Code Never, lol my name is Coder Never
The R is Silent
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us