Solved

Copy files with VB

Posted on 1998-11-04
6
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

696 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