Sub Spezzetta(Dir As String, FileName As String, Spezzoni As Int)
Dim FileSize As Long = File.Size(Dir, FileName)
Dim Spezzoni As Int = 10
Dim Spezzone As Int = FileSize / Spezzoni
Dim Resto As Int = FileSize Mod Spezzone
Log("File size: " & FileSize)
Log("Spezzone " & Spezzone)
Log("Resto: " & Resto)
Dim rasInput As RandomAccessFile
rasInput.Initialize(Dir, FileName, True)
Dim FileNum As Int = 1
For i = 0 To Spezzoni * Spezzone - 1 Step Spezzone
Dim Buffer(Spezzone) As Byte
rasInput.ReadBytes(Buffer, 0, Spezzone, i)
Dim rasOutput As RandomAccessFile
rasOutput.Initialize(Dir, FileNum & "_" & FileName, False)
rasOutput.WriteBytes(Buffer, 0, Spezzone, 0)
rasOutput.Flush
rasOutput.Close
FileNum = FileNum + 1
Next
' Resto
Dim Buffer(Resto) As Byte
rasInput.ReadBytes(Buffer, 0, Resto, i)
Dim rasOutput As RandomAccessFile
rasOutput.Initialize(Dir, i & "_" & FileName, False)
rasOutput.WriteBytes(Buffer, 0, Resto, 0)
rasOutput.Flush
rasOutput.Close
rasInput.Close
End Sub