943,829 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 5368
  • VB.NET RSS
Jan 5th, 2009
0

merging two txt files into one txt file

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nmakkena is offline Offline
14 posts
since Dec 2008
Jan 5th, 2009
1

Re: merging two txt files into one txt file

VB.Net makes a task like that quite simple:
VB.NET Syntax (Toggle Plain Text)
  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:
VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 22
Solved Threads: 1
Newbie Poster
robert_c_guy is offline Offline
4 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: combobox
Next Thread in VB.NET Forum Timeline: Listview Column data to XML file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC