Console application: save strings to a file

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

How can I save a string (or multiple strings) to a file (normal plain text in the curdir() ) in a console application?
Practice makes perfect!

VIP since: 6-10-2011
User avatar
bisnes_niko
Serious Programmer
Serious Programmer
Posts: 409
Joined: Tue Aug 24, 2010 1:21 pm

Code: Select all
Module modMain
    Dim exit_app As Boolean
    Dim content As String
    Sub Main()
        Process.Start(CurDir)
        While Not exit_app
            Dim line As String = Console.ReadLine
            If line = "write" Then
                My.Computer.FileSystem.WriteAllText("file.txt", content, False)
            Else
                content += line & vbNewLine
            End If
        End While
    End Sub
End Module
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Ill try it tomorrow, got not so much spare time today. Thx for the effort alrdy Niko!
Practice makes perfect!

VIP since: 6-10-2011
3 posts Page 1 of 1
Return to “Coding Help & Support”