Click here to Skip to main content
11,922,641 members (56,504 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked

Copy binary folder files

, 25 Dec 2003
Rate this:
Please Sign up or sign in to vote.
EZ methods to copy a complete folder, while filtering the filetypes as needed.


I needed a dirty method for copying my image folder.

Just use: WriteFolder txtSRCPATH, txtDESTPATH

Option Explicit

Private Sub Form_Load()

End Sub

Private Sub cmdCOPY_Click()
    WriteFolder txtSRCPATH, txtDESTPATH
End Sub
Sub WriteFolder(ByVal fsrc As String, ByVal fdes As String)

Dim Buffer() As Byte
Dim fname As String

    fname = Dir(fsrc, vbArchive)

    Do While fname <> ""
        If (InStr(1, fname, "jpeg", vbBinaryCompare) > 0 
              Or InStr(1, fname, "gif", vbBinaryCompare) > 0) Then
            WriteFile fdes & fname, ReadFile(fsrc & fname, Buffer())
        End If
        fname = Dir()

End Sub

Function ReadFile(fname As String, Buffer() As Byte) As Byte()

Dim fh, flen As Long

    fh = FreeFile
    Open fname For Binary Access Read As #fh
    flen = LOF(fh)
    Buffer = InputB(flen, #fh)
    Close #fh

ReadFile = Buffer()

End Function
Sub WriteFile(fname As String, Buffer() As Byte)

Dim fh As Long

    fh = FreeFile
    Open fname For Binary Access Write As #fh
    Put #fh, , Buffer
    Close #fh

End Sub

The WriteFolder method passes "jpeg" and "gif" files only. (You can change this as needed.)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
Hubris is like armor. He is afraid to take on a Coder project for what it may do to him, both financially and to his health.

WEB Bowser is a hack that makes it easy to acquire internet content for archival. Its also possible to PROXY it, serving it to the internet as well. Given this capability, people will change the internet again.

I envision a programmable server that will acquire content for proxy. Users will then add proxy content to their own, making it available almost as if it were their own. We are already "information collectors." Its the opinions that are getting real hard to find.


You may also be interested in...

Comments and Discussions

Generalwrong section Pin
5150@abrichardson.com10-Oct-05 8:12
member5150@abrichardson.com10-Oct-05 8:12 
QuestionBinary Compare? Pin
Heath Stewart28-Dec-03 5:37
editorHeath Stewart28-Dec-03 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151125.1 | Last Updated 26 Dec 2003
Article Copyright 2003 by QUIETTA
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid