title: VB.NET merge large files
body: <p>I wish to use VB.NET to replace a batch file that merged large files.  This is because the batch file just hangs when running as a scheduled job.  (The batch file works fine everywhere else; but not as a SQL job.)</p>
  
  <p>The batch file performed these steps:
  copy "\server\network location\large_file1.txt" + "\server\network location\large_file2.txt" + "\server\network location\large_file3.txt"</p>
  
  <p>The files are quite large and I don't wish to open any of them.  I think the server running the job might run out of memory.</p>
  
  <p>Can this be done in VB.NET?  </p>
  
  <p>thanks!</p>
  
  <p><strong>UPDATE:</strong> Solution from user's comment:</p>
  
  <pre><code>Dim myBuffer(4096) As Byte 
  Dim fsdest As System.IO.FileStream 
  Dim fsSecondFile As System.IO.FileStream fsdest = New System.IO.FileStream(strDestinationfile, System.IO.FileMode.Append) 
  
  fsSecondFile = New System.IO.FileStream(strSecondFile, IO.FileMode.Open, IO.FileAccess.Read) 
  
  Do While fsSecondFile.Read(myBuffer, 0, myBuffer.Length) &gt; 0 
      fsdest.Write(myBuffer, 0, 4095) 
  Loop 
  
  fsdesc.close() 
  fsSecondFile.close()
  </code></pre>