merging two txt files into one txt file

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 13
Reputation: nmakkena is an unknown quantity at this point 
Solved Threads: 0
nmakkena nmakkena is offline Offline
Newbie Poster

merging two txt files into one txt file

 
0
  #1
Jan 5th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: robert_c_guy is an unknown quantity at this point 
Solved Threads: 0
robert_c_guy robert_c_guy is offline Offline
Newbie Poster

Re: merging two txt files into one txt file

 
1
  #2
Jan 5th, 2009
VB.Net makes a task like that quite simple:
  1. Public Sub text_combine( _
  2. ByVal path_to_read_file As String, _
  3. ByVal path_to_append_file As String _
  4. )
  5. System.IO.File.AppendAllText( _
  6. path_to_append_file, _
  7. System.IO.File.ReadAllText(path_to_read_file) _
  8. )
  9. End Sub
A little error checking may prevent hangups:
  1. Public Function text_combine( _
  2. ByVal path_to_read_file As String, _
  3. ByVal path_to_append_file As String _
  4. ) As Boolean
  5. If ( _
  6. (IO.File.Exists(path_to_read_file)) _
  7. And (IO.File.Exists(path_to_append_file)) _
  8. ) Then
  9. Try
  10. System.IO.File.AppendAllText( _
  11. path_to_append_file, _
  12. System.IO.File.ReadAllText(path_to_read_file) _
  13. )
  14. text_combine = True
  15. Catch ex As Exception
  16. text_combine = False
  17. End Try
  18. Else
  19. text_combine = False
  20. End If
  21. End Function
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC