Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge 2 files into 1 file

Status
Not open for further replies.

confuseddddd

Programmer
May 22, 2003
53
US
Does anyone know how to accomplish this??? I am newbie to .net and would like some assistance, either by giving me some websites where I can browse around to find some material on accomplishing this or giving me some book names to read on going about merging files into one file. It will be the same format of each file, its just one is being generated in unix and one is being generated of vb and need to merge the files together.
Any input would be most wonderful.
Thanks
 
Not the cleanest, but it's someplace to start:
Code:
    Dim sIn1 As New System.IO.FileStream("textfile1.txt", IO.FileMode.Open)
    Dim sIn2 As New System.IO.FileStream("textfile2.txt", IO.FileMode.Open)
    If System.IO.File.Exists("Output.txt") Then System.IO.File.Delete("Output.txt")
    Dim sOut As New System.IO.FileStream("Output.txt", IO.FileMode.CreateNew)
    Dim EoF As Boolean = False

    While Not EoF
      Try
        sOut.WriteByte(sIn1.ReadByte())
      Catch
        EoF = True
      End Try
    End While
    sIn1.Close()
    EoF = False

    While Not EoF
      Try
        sOut.WriteByte(sIn2.ReadByte())
      Catch
        EoF = True
      End Try
    End While
    sIn2.Close()
    sOut.Close()

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top