JoinBinaryFiles – Joining a variable number of binary files into a single file

JoinBinaryFiles – Joining a variable number of binary files into a single file

' Join a variable number of binary files into a single file'' Params:'  - resultFile: the complete path of the result file you want to create'  - sourceFiles: the sequence of files whose content will be joined together'' Example:'   JoinBinaryFiles("D:Test.bin", "D:Source1.bin", "D:Source2.bin",'  "D:Source3.bin")Sub JoinBinaryFiles(ByVal resultFile As String, ByVal ParamArray sourceFiles() _    As String)    ' if the result file already exists, delete it    If System.IO.File.Exists(resultFile) Then        System.IO.File.Delete(resultFile)    End If    ' create the destination file and open it in write mode    Dim fsw As New System.IO.FileStream(resultFile, _        System.IO.FileMode.CreateNew)    Dim writer As New System.IO.BinaryWriter(fsw)    ' open each input file in read mode, and copy its content to the     ' destination file    Dim fpath As String    For Each fpath In sourceFiles        Dim fsr As System.IO.FileStream        Dim reader As System.IO.BinaryReader        Try            ' create the reader for this file            fsr = New System.IO.FileStream(fpath, System.IO.FileMode.Open, _                System.IO.FileAccess.Read)            reader = New System.IO.BinaryReader(fsr)            ' read the binary content and write it to the destination file            writer.Write(reader.ReadBytes(fsr.Length))        Catch e As Exception            ' if there is an exception, close the writer and re-throw the             ' exception            ' so that the routines terminates. The reader is closed in the             ' Finally block below            writer.Close()            fsw.Close()            Throw e        Finally            If Not reader Is Nothing Then                reader.Close()                fsr.Close()            End If        End Try    Next    ' close the writer    writer.Close()    fsw.Close()End Sub

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes