Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Simple Text File Merger + Source

Here is a simple too I made, It simply allows you to select a folder with multiple .txt or .xml files and merge them into a single .txt or .xml file.

Screenshot:
[Image: 4gdsLbS.png]

Code
Public Class TextFileMerger
    Dim X, Y As Integer
    Dim NewPoint As New System.Drawing.Point

#Region "Move Panel"
    Private Sub Panel1_MouseDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
      X = Control.MousePosition.X - Me.Location.X
      Y = Control.MousePosition.Y - Me.Location.Y
    End Sub
    Private Sub Panel1_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
      If e.Button = Windows.Forms.MouseButtons.Left Then
      NewPoint = Control.MousePosition
      NewPoint.X -= (X)
      NewPoint.Y -= (Y)
      Me.Location = NewPoint
      End If
    End Sub
    Private Sub Label1_MouseDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
      X = Control.MousePosition.X - Me.Location.X
      Y = Control.MousePosition.Y - Me.Location.Y
    End Sub
    Private Sub Label1_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
      If e.Button = Windows.Forms.MouseButtons.Left Then
      NewPoint = Control.MousePosition
      NewPoint.X -= (X)
      NewPoint.Y -= (Y)
      Me.Location = NewPoint
      End If
    End Sub
#End Region

#Region "Buttons"
    Private Sub MinimizeB_Click(sender As Object, e As EventArgs) Handles MinimizeB.Click
      Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
    End Sub
    Private Sub CloseB_Click(sender As Object, e As EventArgs) Handles CloseB.Click
      Me.Close()
    End Sub
    Private Sub OpenB_Click(sender As Object, e As EventArgs) Handles OpenB.Click
      SelectFolder()
    End Sub
    Private Sub MergeB_Click(sender As Object, e As EventArgs) Handles MergeB.Click
      FormatCheck()
    End Sub
#End Region

#Region "Work"
    Sub SelectFolder()
      Using FD As New FolderBrowserDialog
      If FD.ShowDialog = Windows.Forms.DialogResult.OK Then
            FolderDirT.Text = (FD.SelectedPath.ToString)
            StatusT.Text = (FD.SelectedPath.ToString + " Selected!")
      End If
      End Using
    End Sub
    Sub FormatCheck()
      If RadioButton1.Checked = True Then
      StatusT.Text = "Format = Text"
      Txtmerge()
      ElseIf RadioButton2.Checked = True Then
      StatusT.Text = "Format = XML"
      Xmlmerge()
      Else
      MessageBox.Show("Please Select a format to continue.")
      StatusT.Text = "No Format Selected!"
      End If
    End Sub
    Sub Txtmerge()
      Dim myprocess As New Process
      Dim StartInfo As New System.Diagnostics.ProcessStartInfo
      StartInfo.FileName = "cmd"
      StartInfo.RedirectStandardInput = True
      StartInfo.RedirectStandardOutput = True
      StartInfo.UseShellExecute = False
      myprocess.StartInfo = StartInfo
      myprocess.Start()
      Dim SR As System.IO.StreamReader = myprocess.StandardOutput
      Dim SW As System.IO.StreamWriter = myprocess.StandardInput
      SW.WriteLine("copy *.txt " + TextBox2.Text + ".txt")
      StatusT.Text = SR.ReadToEnd
      StatusT.Text = SR.ReadToEnd
      SW.WriteLine("exit")
      SW.Close()
      SR.Close()
      StatusT.Text = "Merging txt Files Finished!"
      MessageBox.Show("Finished! All Files Merged Into " + FolderDirT.Text + "\" + TextBox2.Text + ".txt")
    End Sub
    Sub Xmlmerge()
      Dim myprocess As New Process
      Dim StartInfo As New System.Diagnostics.ProcessStartInfo
      StartInfo.FileName = "cmd"
      StartInfo.RedirectStandardInput = True
      StartInfo.RedirectStandardOutput = True
      StartInfo.UseShellExecute = False
      myprocess.StartInfo = StartInfo
      myprocess.Start()
      Dim SR As System.IO.StreamReader = myprocess.StandardOutput
      Dim SW As System.IO.StreamWriter = myprocess.StandardInput
      SW.WriteLine("copy *.xml " + TextBox2.Text + ".xml")
      StatusT.Text = SR.ReadToEnd
      StatusT.Text = SR.ReadToEnd
      SW.WriteLine("exit")
      SW.Close()
      SR.Close()
      StatusT.Text = "Merging XML Files Finished!"
      MessageBox.Show("Finished! All Files Merged Into " + FolderDirT.Text + "\" + TextBox2.Text + ".xml")
    End Sub
#End Region
End Class

Source Code DL: http://www.mediafire.com/download/c5x5xe...Merger.zip
https://www.virustotal.com/en/file/c2997...423126733/
.exe DL: http://www.mediafire.com/download/0ufh12...Merger.exe
Why is CMD getting involved? Pretty much all of this can be condensed:

Code
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
    Dim di As New DirectoryInfo(fbd.SelectedPath)
    File.WriteAllLines(Path.Combine(fbd.SelectedPath, "merged.txt"), di.GetFiles().SelectMany(Function(f) File.ReadAllLines(f.FullName)))
End If
(Feb 5, 2015 10:33 AM)Odus Wrote:  Why is CMD getting involved? Pretty much all of this can be condensed:

Code
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
    Dim di As New DirectoryInfo(fbd.SelectedPath)
    File.WriteAllLines(Path.Combine(fbd.SelectedPath, "merged.txt"), di.GetFiles().SelectMany(Function(f) File.ReadAllLines(f.FullName)))
End If

I see that, I will update the program using that idea, I just had a use for this program and only knew how to do it in CMD that is why I did it like that
Here. Learn a few things.
Code
while(entry)
{
memcpy(buf,entry->data,entry->size);
entry += entry->nextOffset;
buf+=entry->size;
}
👹


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Robert RougeMar 26, 2025 10:50 PM 1 288 Mar 26, 2025 10:50 PM
Last Post: cote
[.NET] by sh@rpJul 5, 2020 07:05 AM 212 22,347 Jul 5, 2020 07:05 AM
Last Post: sh@rp
[C] by pebblakOct 15, 2019 05:24 AM 6 304 Oct 15, 2019 05:24 AM
Last Post: Joseph Ducreux