Solved

Copy files with VB

Posted on 1998-11-04
6
387 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
Comment Utility
'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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 18

Expert Comment

by:deighton
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help !!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

11 Experts available now in Live!

Get 1:1 Help Now