Solved

VB6 - A simple FTP directory synchronizer

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now