Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy files with VB

Posted on 1998-11-04
6
Medium Priority
?
414 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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