This code will cut files in 2 pieces at specified length or file split a large file into multiple o
This code will cut files in 2 pieces at specified length or file split a large file into multiple ones.
Rate This code will cut files in 2 pieces at specified length or file split a large file into multiple o
(1(1 Vote))
'#Code Made by: #
'#John Maskeny #
'#07/26/00 #
'#[email protected]#
Public Function SplitFile(ByVal StartFile As String, SplitSize As Long, MultiFile As Boolean)
Dim OpenFile As Integer, FileSplit As String, LenFile As Long, SplitPos As Long, Openfile2 As Integer, i As Integer, count As Integer
SplitPos = 1 ' Starting position
If StartFile <> "" Then ' Error checking
OpenFile = FreeFile
Open StartFile For Binary Access Read As OpenFile 'Open sourcefile
LenFile = LOF(OpenFile) 'File length
count = 0 ' reset count
Do Until SplitPos >= (LenFile) 'do to end of file
count = count + 1 'add 1 to count
Openfile2 = FreeFile
Open StartFile & count For Binary As Openfile2 'open destination file
If count > 1 And MultiFile = False Then 'if not multi file then we just want to cut it
FileSplit = Space$(LenFile - SplitSize)
Else
FileSplit = Space$(SplitSize) 'else make and many sets as sized
End If
Get #OpenFile, SplitPos, FileSplit ' Get chunk
If SplitPos + SplitSize > LenFile Then ' if at end of file get the rest
Put #Openfile2, , Mid$(FileSplit, 1, (LenFile - SplitPos))
Else
Put #Openfile2, , FileSplit
End If
If count > 1 And MultiFile = False Then ' if not multi file we only want 2 parts
SplitPos = LenFile
Else
SplitPos = SplitPos + SplitSize
End If
Close #Openfile2 'close file
Loop
Close #OpenFile
End If
End Function
This code will cut files in 2 pieces at specified length or file split a large file into multiple o Comments
No comments yet — be the first to post one!
Post a Comment