Hi,

Actully i wanted to merge two txt files into one txt file. (i.e. second file has to be appended to the first file). please give me some solution for my problem. I am new to vb.net, so pls elaborate the solution.

Thanks in advance.

VB.Net makes a task like that quite simple:

Public Sub text_combine( _
        ByVal path_to_read_file As String, _
        ByVal path_to_append_file As String _
    )
        System.IO.File.AppendAllText( _
            path_to_append_file, _
            System.IO.File.ReadAllText(path_to_read_file) _
        )
    End Sub

A little error checking may prevent hangups:

Public Function text_combine( _
        ByVal path_to_read_file As String, _
        ByVal path_to_append_file As String _
    ) As Boolean
        If ( _
            (IO.File.Exists(path_to_read_file)) _
            And (IO.File.Exists(path_to_append_file)) _
        ) Then
            Try
                System.IO.File.AppendAllText( _
                    path_to_append_file, _
                    System.IO.File.ReadAllText(path_to_read_file) _
                )
                text_combine = True
            Catch ex As Exception
                text_combine = False
            End Try
        Else
            text_combine = False
        End If
    End Function
commented: Nice Code. +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.