Page 1 of 1

textbox save it as .txt file

Posted: Thu Nov 28, 2013 4:27 pm
by troop
ok ! this might be hard but i need to know :(, i already see many tutorials for making notepad save/open feature but the program im making doesnt need that with dialogs i mean

i just want people to press Save it will save texbox1.text in a saved1.txt in C:/test/
and then they press open it will open saved1.txt from C:/test/saved1.txt into textbox1.text

if this is possible without dialog boxes tell me :D loove;

Re: textbox save it as .txt file

Posted: Thu Nov 28, 2013 4:45 pm
by Dummy1912
hello #troop

you can always try it like this:

'save
Code: Select all
                    Dim sr As New System.IO.StreamWriter("c:\test\saved1.txt")
                    Dim s As String = TextBox1.Text
                    sr.Write(s)
                    sr.Close()
'open
Code: Select all
                Dim sr As New System.IO.StreamReader("c:\test\saved1.txt")
                TextBox1.Text= sr.ReadToEnd
                sr.Close()


Re: textbox save it as .txt file

Posted: Thu Nov 28, 2013 4:58 pm
by troop
i will try this now :D
#Dummy_Is_best #Thanks :D

Re: textbox save it as .txt file

Posted: Thu Nov 28, 2013 5:23 pm
by troop
works :D
after watching many tutorials my brother told me to create a login system without looking in youtube, he asked me to do it with those checks, Check username chars to be + 2 and password match etc

do u like my codes guys :D
Code: Select all
    Try
            If My.Computer.FileSystem.DirectoryExists(Loc) Then
            Else
                My.Computer.FileSystem.CreateDirectory(Loc & "\accounts\")
            End If


            If txtBox3.Text.Length < 2 Then
                MsgBox("Your username should be more than 2 characters!")
            Else
                If txtBox4.Text = Nothing Then
                    MsgBox("Please enter a password")
                Else
                    Dim accLoc As String = Loc & "\accounts\" & txtBox3.Text & "\password.txt"
                    If My.Computer.FileSystem.DirectoryExists(accLoc) Then
                        MsgBox("Account already exist")
                    Else
                        If txtBox4.Text = txtBox5.Text Then
                            My.Computer.FileSystem.CreateDirectory(Loc & "\accounts\" & txtBox3.Text & "\")
                            Dim sr As New System.IO.StreamWriter(accLoc)
                            Dim s As String = txtBox4.Text
                            sr.Write(s)
                            sr.Close()
                            MsgBox("Account successfully created, we will auto login you!")
                            txtBox1.Text = txtBox3.Text
                            txtBox2.Text = txtBox4.Text
                            txtBox3.Clear() : txtBox4.Clear() : txtBox5.Clear()
                            btnLog.PerformClick()

                        Else
                            MsgBox("Please comfirm your password")
                        End If
                    End If
                End If
            End If
        Catch ex As Exception
            MsgBox(ErrorToString)
        End Try
sorry i used dummy code for saving :D

Re: textbox save it as .txt file

Posted: Thu Nov 28, 2013 9:40 pm
by comathi
It's a nice way of learning, but just don't use it to store any actual passwords :lol:

Plain text files are the least secure method for keeping confidential information.

Re: textbox save it as .txt file

Posted: Fri Nov 29, 2013 1:46 am
by dualz
indeed they are not good, ok for limited information but not the likes of passwords or even usernames.

when it comes to storing say save username into any of my applications i create a hex key and store it in the registry.

passwords are always base64 encrypted to my mssql server's and as an extra security feature depending on the application i write i also add a usb key so you have to have the usb device plugged in or it wont even get to the login screen :d

Re: textbox save it as .txt file

Posted: Fri Nov 29, 2013 7:44 am
by troop
im making a simple game i found a tutorial on here, i will tell ueverything about it later but i mean this is not a real huge app its ok if they see passwords ;p