2 Replies - 416 Views - Last Post: 29 April 2010 - 07:12 AM Rate Topic: -----

#1 monstratonis  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 63
  • Joined: 18-April 10

streamWritter arrays to text file

Posted 29 April 2010 - 01:31 AM

lads, I'm having problems with saving user input to text file. Need use the streamWritter to write users names and passwords to text file I gues the arrays would work out but the code is mess and I'm stock with this:
[code]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim file As System.IO.StreamWriter
Dim dir As String = "c:\base.text"

If file.Exists("c:\base.txt") Then
file = My.Computer.FileSystem.OpenTextFileWriter("c:\base.txt", True)
file = appendText("strUserName")
Else
My.Computer.FileSystem.CreateDirectory(dir)
file = New StreamWriter("C:\base.txt")

file.Close()
End If
End Sub

Is This A Good Question/Topic? 1
  • +

Replies To: streamWritter arrays to text file

#2 r1zla  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 142
  • Joined: 04-February 10

Re: streamWritter arrays to text file

Posted 29 April 2010 - 01:57 AM

The following is a simple example of how to use a streamwriter to write a text file. Excuse if my syntax is slightly off but I can't type code to save my life without visual studio to correct my errors :)

Dim writer as new streamwriter(dir)
Dim dir as string = "C:\test.txt"

writer.writeline(username & " " & password)
writer.close()



Hope it helps.
Was This Post Helpful? 0
  • +
  • -

#3 code_junkie83  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 62
  • Joined: 17-June 09

Re: streamWritter arrays to text file

Posted 29 April 2010 - 07:12 AM

Just a quick note on r1zla's code, be sure to declare dir before using it in the streamwriter declaration :) And you may need to open the streamwriter, but I'm not 100% on that one. Otherwise, that's the short and long of it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1