Link to home
Start Free TrialLog in
Avatar of dgb
dgb

asked on

Copy files with VB

How can i copy files larger than 1.44 mb to floppy disk
using VB-statements or API-calls (NOT using pkzip or any other compress application !!!)

All i want to know is how to read x bytes from the source file into a buffer and write the buffer to the destination file until eof or ???? bytes copied
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgb
dgb

ASKER

Thanks for your code
It works well, but it's quiet slow
Is it possible to read more then 1 byte at a time, 1024 for example ??
Hi dgb
Maybe try using pkzip in dos . Open into dos using the command or shell functionsand assighn the file to pkzip automatically with the right parameters for spanning over multiple disks , it could maybe be faster

How about this change.  Any improvement?

'iBlocks is the size of your block for each file e.g
'1400000
'sSource is your source file path
Private Function Splitter(sSource As String, iBlocks As Long)

    Dim iFile As Integer
    Dim iFile2 As Integer
    Dim iByte As Long
    Dim iDisk As Long
   
    Dim sX As String
   
    Dim lSize As Long    'this is the size of each block
   
   
    lSize = 32767
    If lSize > iBlocks Then lSize = iBlocks
   
    sX = String(lSize, " ")
   
    iFile = FreeFile
   
    Open sSource For Binary As iFile
   
    For iByte = 1 To LOF(iFile) Step lSize
   
        If (iByte - 1) Mod iBlocks = 0 Then
       
            iDisk = iDisk + 1
       
            MsgBox "insert disk #" & CStr(iDisk)
            If iByte <> 1 Then Close iFile2
            iFile2 = FreeFile
           
            Open "a:file" & CStr(iDisk) For Binary As iFile2
           
        End If
       
        If LOF(iFile) - iByte < lSize Then
       
            sX = String(LOF(iFile) - iByte, " ")
           
        End If
           
        Get #iFile, , sX
       
        Put #iFile2, , sX
       
    Next
   
    Close #iFile, #iFile2
   
   
   
    MsgBox "FIN"
   
   


End Function

IMPORTANT AMENDMENT

Private Sub Command1_Click()

'the block size has to be an exact multiple of the lsize value in the function!
    Call Splitter("c:\temp\install\vb40016.dll", 32767& * 20&)
   
   
End Sub

Avatar of dgb

ASKER

Thanks for your help !!