Solved

VB6 - A simple FTP directory synchronizer

Posted on 2003-11-24
1
496 Views
Last Modified: 2010-04-17
I'm trying to make an ftp app that basically does directory synchronization, but I suck at programming.
I would like to figure out how to take each file name in the remote ftp directoy and compare it to the contents of a local directory and upload only the files that are in the local directory but not on the server. Also Delete any files that are on the server that are Not in the local directory.

I'm thinking perhaps it would be easier to use List Boxes then compare the two or something like that.

Can someone help me out with this please :)

Heres the code I have so far...


[code]
Private Sub cmdConnect_Click()
    Dim BUFFER() As String
    Dim ITEM As Variant
     
    With Inet1
        .URL = "ftp://" & txtIpAddress.Text
        .UserName = txtLogin.Text
        .Password = txtPassword.Text
        .Execute , "DIR"
        While .StillExecuting: DoEvents: Wend
        BUFFER = Split(.GetChunk(1024, icString), vbCrLf)
        For Each ITEM In BUFFER
            If UCase(Right(ITEM, 4)) = ".jpg" Then
'<---Pseudo code because I don't know how to do this

    'LOOK IN "C:\PHOTOS\" AND SEE IF THERE IS A FILE THERE WITH THE SAME NAME
            If THERE IS ONE ALREADY IN "C:\PHOTOS\" WITH THE SAME NAME THEN
                 Skip FILE '<---MOVE TO THE NEXT FILE
                End If
            ElseIf
                IT IS FOUND IN "C:\PHOTOS\" BUT NOT ON THE SERVER THEN
        'writes the name of the file to a listbox
                txtPhotosRemovedFromServer.Text = txtPhotosRemovedFromServer.Text & ITEM
                .Execute , "PUT ITEM" '<---UPLOAD THE FILE
                While .StillExecuting: DoEvents: Wend
                End If
            ElseIf
                If ONE IS FOUND ON THE SERVER THAT IS NOT IN "C:\PHOTOS\" THEN
        'writes the name of the file to a listbox
                txtPhotosUploadedToServer.Text = txtPhotosUploadedToServer.Text & ITEM
                .Execute , "DELETE ITEM" '<---DELETE THE FILE
                While .StillExecuting: DoEvents: Wend
                End If
            End If
'<---End Pseudo code because I don't know how to do this
        Next
    End With
End Sub
[/code]
0
Comment
Question by:Matrix1000
1 Comment
 
LVL 9

Accepted Solution

by:
Dang123 earned 250 total points
ID: 9818821
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’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

679 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