Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
Merge two big files
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="jmcilhinney, post: 186087, member: 641"] I haven't read your code in detail but, at a glance, it looks very inefficient. For one thing, you should not be using the state of UI controls to determine the state of reading a file. Just read each file line by line and write out the data line by line. [CODE=vbnet]Sub Main() Using sourceReader1 As New StreamReader("source file 1 path here"), sourceReader2 As New StreamReader("source file 2 path here"), destinationWriter As New StreamWriter("destination file path here") Do Until sourceReader1.EndOfStream AndAlso sourceReader2.EndOfStream If Not sourceReader1.EndOfStream Then TransferData(sourceReader1, destinationWriter) End If If Not sourceReader2.EndOfStream Then TransferData(sourceReader2, destinationWriter) End If Loop End Using End Sub Private Sub TransferData(sourceReader As StreamReader, destinationWriter As StreamWriter) Const TARGET_LINE As String = "target line here" Dim line As String Do line = sourceReader.ReadLine() destinationWriter.WriteLine(line) Loop Until line = TARGET_LINE OrElse sourceReader.EndOfStream End Sub[/CODE] It's still going to take some time if there is a lot of data but it's more straightforward than what you're doing. You may need to adjust it a bit for your specific needs. [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
Merge two big files
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom