Solved

Copy files with VB

Posted on 1998-11-04
6
389 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:dgb
  • 3
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 100 total points
ID: 1443053
'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 Integer
    Dim iDisk As Long
   
    Dim sX As String * 1
   
   
    iFile = FreeFile
   
    Open sSource For Binary As iFile
   
    For iByte = 1 To LOF(iFile)
   
        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
           
        Get #iFile, , sX
       
        Put #iFile2, , sX
       
    Next
   
    Close #iFile, #iFile2
   
   
   
    MsgBox "FIN"
   
   


End Function


0
 

Author Comment

by:dgb
ID: 1443054
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 ??
0
 
LVL 4

Expert Comment

by:CraigLazar
ID: 1443055
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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:deighton
ID: 1443056
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

0
 
LVL 18

Expert Comment

by:deighton
ID: 1443057
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

0
 

Author Comment

by:dgb
ID: 1443058
Thanks for your help !!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now