Solved

VB6 - A simple FTP directory synchronizer

Posted on 2003-11-24
1
493 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 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