Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15549

vb.net combine multiple text files

$
0
0
Hi All... I am using this code to combine text files. How can I add a carriage return after each file?

I need this output:

Code:

Apple
Banana
Orange

Not like this code is doing:

Code:

AppleBananaOrange
Code:

Imports System.IO
Imports System.Text

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim newDateFormat As String
        newDateFormat = DateTime.Now.ToString("MM.dd.yyyy_mm.HH.ss")
        Dim prgPath As String = IO.Path.GetDirectoryName(Application.ExecutablePath)

        Dim Paths() As String = Directory.GetFiles(prgPath, "*.txt")
        For Each Path As String In Paths
            File.AppendAllText("Combined_" & newDateFormat & ".txt", File.ReadAllText(Path), Encoding.Default)
        Next



    End Sub
End Class


Viewing all articles
Browse latest Browse all 15549

Trending Articles