Write 2 VB.NET functions that will split and merge a file.
Must support large files (>8GB). Do not allocate larger memory block than 100MB at a time, reuse same buffer to avoid outofmemory exceptions.
[login to view URL] splitFile(ByVal filepath As String, ByVal parts As Integer) As String
[login to view URL] mergeFile(ByVal filepathList As String, ByVal destFilepath As String) As String
## Deliverables
'Function splitFile will create new files by splitting one file into selected number of parts.
'The parts will be placed in the same directory as the original file.
'Each part will be renamed as <ORIGINALNAME>_<ORIGINALEXTENSION>.segment<partnumber>
'Use function getPartName for names
'Example the file "[login to view URL]" will be splitted into [login to view URL], [login to view URL], [login to view URL]" etc
'The function returns a list of full filepaths to the parts
'Each part should have nearly equal filesize
'The function must be able to handle large files >8GB, and may not allocate larger block than 100MB.
Function splitFile(ByVal filepath As String, ByVal parts As Integer) As String
End Function
'Function mergeFile will create a new file by merging parts.
'The parts are named as [login to view URL], [login to view URL], [login to view URL] etc
'and the resulting file is the called "[login to view URL]"
'The function returns destFilepath which is the full filepath to the merged file
Function mergeFile(ByVal filepathList As String, ByVal destFilepath As String) As String
End Function
'Use this function for a basic reality check of the result
Function validateSplitMerge(ByVal filepath As String)
Dim destFilepath As String = Replace(filepath, ".", "_2.")
Dim mergedFile As String = mergeFile(splitFile(filepath, 7), destFilepath)
If getTheFileSize(filepath) <> getTheFileSize(destFilepath) Then
Return "basic test failed, size of the new file is not the same as the original"
Else
Return "new file " & destFilepath & " has same size as original file. Please verify content of the files."
End If
End Function