Question

Explain This FTP Program?!?!?!?!

Asked by: sjaguar13

I need help with this ftp program. I want to do stuff with it but don't know how some stuff works. I don't just want to copy and paste because that teaches me nothing. I really need to get the basics with it. I know how to get it to connect to the host but I get lost when it comes to the password and the username. If you need more code (this is just the main form) or if you want the whole source code, just ask.

Option Explicit
Private PrevButton
Dim Buffer As Integer
Dim States(8) As Com ' initialize the command/reply array
Dim state As Integer
Dim FirstTime As Boolean
Dim CancelFlag As Boolean
Dim akm As Integer
Dim ama As Integer
Dim aza As String
Dim Nr1 As Integer, Nr2 As Integer, num1 As String
Dim LocalIP As String
Dim prts As String
Dim bReplied As Boolean
Dim lTime As Long
Dim MessCnt As Integer
Dim t As Integer
Dim restr As String
Dim numberof As Integer
Dim rmdata As String, trans
Dim x1, y1 As Integer
Sub ButtonUp(Index)
CoolBarImage(Index).Left = CoolBarImage(Index).Left - 10
CoolBarImage(Index).Top = CoolBarImage(Index).Top - 10
Coolbar(Index).Left = Coolbar(Index).Left - 10
Coolbar(Index).Top = Coolbar(Index).Top - 10
Coolbar(Index).Height = Coolbar(Index).Height + 40
Coolbar(Index).Width = Coolbar(Index).Width + 40
   
End Sub
Sub ButtonDown(Index)
Label3.Caption = ""
CoolBarImage(Index).Left = CoolBarImage(Index).Left + 10
CoolBarImage(Index).Top = CoolBarImage(Index).Top + 10
Coolbar(Index).Left = Coolbar(Index).Left + 10
Coolbar(Index).Top = Coolbar(Index).Top + 10
Coolbar(Index).Height = Coolbar(Index).Height - 40
Coolbar(Index).Width = Coolbar(Index).Width - 40
   
End Sub
Sub MoveMouse(Index)
If Index <> PrevButton Then
    On Error Resume Next
        Coolbar(PrevButton).BorderStyle = 0
End If
   
    PrevButton = Index
    Coolbar(Index).BorderStyle = 1
    CoolBarImage(Index).Visible = True

End Sub
Function loadSaved() As Boolean
Dim ans As String
chgDirRm = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir")
chgDirLc = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir")
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask")
If ans = "" Or ans = "No" Then
UseMask.Value = 0
End If
If ans = "Yes" Then
UseMask.Value = 1
End If

ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal")
If ans = "" Or ans = "No" Then
chkLc.Value = 0
Remote_mask = ""
End If
If ans = "Yes" Then
chkLc.Value = 1
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Local")
Local_mask = ans
End If

ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote")
If ans = "" Or ans = "No" Then
chkRm.Value = 0
Remote_mask = ""
End If
If ans = "Yes" Then
chkRm.Value = 1
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Remote")
Remote_mask = ans
End If

ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound")
If ans = "" Or ans = "Yes" Then
chkSounds.Value = 1
End If
If ans = "No" Then
chkSounds.Value = 0
End If

End Function
Function SendFile()
Dim temp As String
If doing_multi = False Then
cmdCancel.Enabled = True
End If
If halt_transfer = True Then
Progress.Position = 0
Exit Function
End If

Buffer = 4096
If doing_multi = False Then
Progress.Max = LOF(10)
End If
client.total_size = LOF(10)
multiMove.ProgressBar1.Max = (LOF(10) / 100)

With client
If Buffer > (.total_size - .transferBytesSent) Then
            Buffer = (.total_size - .transferBytesSent)
        End If
temp = Space$(Buffer)
        Get 10, , temp
.transferBytesSent = .transferBytesSent + Buffer
.transferTotalBytes = .transferTotalBytes + Buffer
trans = trans + .transferTotalBytes
If doing_multi = False Then
Progress.Position = .transferTotalBytes
Else
trans = trans / 100
multiMove.ProgressBar1.Position = trans
End If
End With
data.SendData temp

End Function
Sub WaitFor(WaitFor As String)
On Error Resume Next
Do While Response <> WaitFor
DoEvents
Loop

Response = 0
End Sub
Public Sub open_file(filename As String)
On Error GoTo here

    If Right(Local_Dir, 2) = "\\" Then
    Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
    End If
    Open (Local_Dir & restr) For Binary Access Write As #1

here:
DoEvents
End Sub
Public Sub Connect()
Dim J
On Error GoTo wrongnum
J = FTPLogin.Host.Text
ServerLog.Clear
state = 0
con.Close
data.Close
Call ipeer
With con
.RemoteHost = J
.RemotePort = FTPLogin.Text1.Text
.LocalPort = Int(Rnd * 99) + 5
.Connect
End With

lTime = 0
    While (Not bReplied) And (lTime < 250000)
        DoEvents
        lTime = lTime + 1
    Wend
   
    If lTime >= 250000 Then
    MsgBox "    Unable to Connect to Host.     ": DoEvents
    lTime = 0
       con.Close
        Unload FTPLogin
    End If
    Exit Sub
   
wrongnum:
Call Wait(0.25)
   
J = FTPLogin.Host.Text
ServerLog.Clear
state = 0
con.Close
data.Close
Call ipeer
With con
.RemoteHost = J
.RemotePort = FTPLogin.Text1.Text
.LocalPort = Int(Rnd * 99) + 5
.Connect
End With

lTime = 0
    While (Not bReplied) And (lTime < 250000)
        DoEvents
        lTime = lTime + 1
    Wend
   
    If lTime >= 250000 Then
    MsgBox "    Unable to Connect to Host.     ": DoEvents
    lTime = 0
       con.Close
        Unload FTPLogin
    End If
    Exit Sub
   
End Sub
Public Sub Disconnect()
ServerLog.Clear
RemoteFiles.Clear
RemoteDirectories.Clear
isit = False
If con.state = sckConnected Then
con.SendData "QUIT" + Chr(13) + Chr(10)
End If
End Sub
Sub ipeer()
On Error GoTo tryagain
data.Close
     LocalIP = con.LocalIP
      Do Until InStr(LocalIP, ".") = 0
           LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
       Loop
       

       Randomize Timer
       Nr1 = Int(Rnd * 12) + 5
       Nr2 = Int(Rnd * 254) + 1
       num1 = "PORT " + LocalIP + "," + Trim(str(Nr1)) + "," + Trim(str(Nr2))
       prts = num1
       data.LocalPort = (Nr1 * 256) + Nr2
       data.RemotePort = Trim(str(Nr2)) ' was nr1
       data.Close
       data.Listen
       Exit Sub
       
tryagain:
Call Wait(0.25)
     data.Close
     LocalIP = con.LocalIP
      Do Until InStr(LocalIP, ".") = 0
           LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
       Loop
       

       Randomize Timer
       Nr1 = Int(Rnd * 12) + 5
       Nr2 = Int(Rnd * 254) + 1
       num1 = "PORT " + LocalIP + "," + Trim(str(Nr1)) + "," + Trim(str(Nr2))
       prts = num1
       data.LocalPort = (Nr1 * 256) + Nr2
       data.RemotePort = Trim(str(Nr2)) ' was nr1
       data.Close
       data.Listen
End Sub
Sub sdelem()

akm = RemoteFiles.ListCount - 1
ama = RemoteFiles.SelCount
Dim anss As String
Dim Cancel1 As Boolean
anss = MsgBox("Delete " & ama & " Files on Remote System?", _
    vbOKCancel + vbQuestion, "Delete Files"): DoEvents
If anss = vbOK Then
    Cancel1 = False
Else

    Cancel1 = True
    GoTo iohoh
End If
dir_info = ""
Screen.MousePointer = vbHourglass

Dim Y
For Y = 0 To akm
If RemoteFiles.Selected(Y) Then
restr = " " & RemoteFiles.List(Y)
restr = Parse(restr, 1)
con.SendData "DELE " & restr + Chr(13) + Chr(10)
End If
WaitFor (250)
Call Wait(0.125)
Next

doing_multi = False
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)

Screen.MousePointer = vbDefault
iohoh:
End Sub
Sub delem()
akm = 0
ama = LocalFiles.SelCount
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Delete " & ama & " Files on Local System?", _
    vbOKCancel + vbQuestion, "Delete Files"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo ohoh
End If
Screen.MousePointer = vbHourglass

Dim Y, ret As Boolean
Y = 0
Do Until Y = LocalFiles.ListCount
If LocalFiles.Selected(Y) Then
ret = ShellDelete(Local_Dir & LocalFiles.List(Y) & Chr(0), FOF_SILENT & FOF_ALLOWUNDO, "")
End If
Y = Y + 1
Call Wait(0.25)
Loop

Screen.MousePointer = 0
RefreshLocal
ohoh:
End Sub
Sub Wait(WaitSeconds As Single)

Dim StartTime As Single

StartTime = Timer

Do While Timer < StartTime + WaitSeconds
DoEvents
Loop
End Sub
Sub RefreshAll()

    RefreshLocal
    RefreshRemote
   
End Sub


Sub RefreshLocal()

    Screen.MousePointer = vbHourglass

Dim NextLocal As String
Dim FullSpec As String
   
    LocalPWD.Caption = CurDir()
    Local_Dir = CurDir()
    Local_Dir = Local_Dir & "\"
    LocalDirectories.Clear
    LocalFiles.Clear
    If Len(CurDir()) = 3 Then
        FullSpec = CurDir() & "*.*"
    Else
        FullSpec = CurDir() & "\*.*"
    End If
    NextLocal = Dir(FullSpec, vbDirectory + vbNormal)
    Do While NextLocal <> ""
        If Len(CurDir()) = 3 Then
            FullSpec = CurDir() & NextLocal
        Else
            FullSpec = CurDir() & "\" & NextLocal
        End If
        On Error Resume Next
       
        If (GetAttr(FullSpec) And vbDirectory) = vbDirectory Then
            LocalDirectories.AddItem NextLocal
        Else
       
        If UseMask.Value = 1 Then
        If chkLc.Value = 1 Then
        If Len(Local_mask) > 3 Then
        masc = "*.*"
        LocalFiles.AddItem NextLocal
        GoTo doit
        End If
        masc = Local_mask
        If masc = "*.*" Then
        LocalFiles.AddItem NextLocal
        GoTo doit
        End If
        If Right(NextLocal, 3) = UCase(masc) Or Right(NextLocal, 3) = LCase(masc) Then
        LocalFiles.AddItem NextLocal
        GoTo doit
        Else
        GoTo doit
        End If
        LocalFiles.AddItem NextLocal
        Else
        LocalFiles.AddItem NextLocal
        End If
        Else
            LocalFiles.AddItem NextLocal
            End If
           
           
        End If
doit:

        NextLocal = Dir
    Loop

    Screen.MousePointer = vbDefault

End Sub

Sub RefreshRemote()
   
    Screen.MousePointer = vbHourglass
    RemoteDirectories.Clear
    RemoteFiles.Clear
    Screen.MousePointer = vbDefault

End Sub

Private Sub ASCIIMode_Click()

    If ASCIIMode.Value = True Then
        FTP.BINARY = False
    End If
   
End Sub

Private Sub BinaryMode_Click()

    If BinaryMode.Value = True Then
        FTP.BINARY = True
    End If
   
End Sub

Private Sub cmdCancel_Click()
If Doing_Upload = True Then
con.SendData "ABOR " + Chr(13) + Chr(10)
halt_transfer = True
Close #10
End If
If Doing_Download = True Then
con.SendData "ABOR " + Chr(13) + Chr(10)
End If
End Sub

Private Sub cmdHelp_Click()
vHelp& = WinHelp(Main.hWnd, App.HelpFile, HELP_INDEX, CLng(0))
End Sub

Private Sub cmdLocal_Click()
Dim ret
ret = BrowseForFolder(Me.hWnd, "Testing")
If ret = "" Then Exit Sub
chgDirLc = ret
End Sub

Private Sub cmdOpt_Click()
If OptFrame.Visible = False Then
OptFrame.Visible = True
Remote.Visible = False
Else
OptFrame.Visible = False
Remote.Visible = True
End If
End Sub

Private Sub cmdRefrLocal_Click()
RefreshLocal
End Sub

Private Sub cmdRefrRemote_Click()
If con.state <> sckConnected Then Exit Sub
On Error GoTo tere
Doing_list = True
dir_info = ""
Call ipeer
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)
WaitFor (257)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "LIST" + Chr(13) + Chr(10)
Exit Sub
tere:
Doing_list = False
Me.MousePointer = 0
End Sub

Private Sub cmdSave_Click()
If chgDirRm.Text <> "" Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir", chgDirRm.Text)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir", "")
End If

If chgDirLc.Text <> "" Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir", chgDirLc.Text)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir", "")
End If

If UseMask.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask", "Yes")
If chkLc.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "Yes")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Local", Local_mask)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "No")
End If
If chkRm.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "Yes")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Remote", Remote_mask)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "No")
End If
End If

If UseMask.Value = 0 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask", "No")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "No")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "No")
End If

If chkSounds.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound", "Yes")
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound", "No")
End If
End Sub

Private Sub Command1_Click()
If con.state <> sckConnected Then Exit Sub
On Error GoTo tere
Doing_list = True
dir_info = ""
Call ipeer
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)
WaitFor (257)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "LIST" + Chr(13) + Chr(10)
RefreshLocal
Exit Sub
tere:
Doing_list = False
Me.MousePointer = 0
End Sub

Private Sub Command2_Click()
On Error GoTo Bottom
frmInfo.txtInf.Text = dir_info
frmInfo.Show
Exit Sub
Bottom:
If Err.Number = 7 Then
MsgBox "Directory to large to list..."
End If
End Sub

Private Sub con_Close()
servu = False
testdir = ""
testfile = ""
Main.Caption = "Dis-Connected"
End Sub

Private Sub con_Connect()
Main.Caption = "Connected - " & con.RemoteHostIP
End Sub

Private Sub con_DataArrival(ByVal bytesTotal As Long)
Dim tmps As String
Dim tri As Integer
Dim tre As String
Dim var As Variant
Dim leng As Integer
Dim ret As Boolean
Dim tmpArray() As String
States(0).BackCode = "220"
States(0).Command = "USER " + FTPLogin.UserName.Text
States(1).BackCode = "331"
States(1).Command = "PASS " + FTPLogin.Password.Text
States(2).BackCode = "230"
States(2).Command = "SYST"
States(3).BackCode = "215"
States(3).Command = "TYPE A"
States(4).BackCode = "200"
If chgDirRm.Text = "" Then
States(4).Command = "PWD "
Else
States(4).Command = ("CWD " + chgDirRm.Text + Chr(13) + Chr(10))
End If
       con.GetData tmps, , bytesTotal
       leng = Len(tmps)
       leng = leng - 4
       tri = Len(tmps)
       tre = Mid(tmps, 1, (tri - 2))
       Response = Mid(tmps, 1, 3)
       
       If Mid(tmps, 1, 3) <> 220 Then  ' Server message and Help
       If Mid(tmps, 1, 3) = 214 Then
       GoTo skip
       End If
       If Mid(tmps, 1, 3) = 530 Then   ' Error message
       GoTo skip
       End If
       If Mid(tmps, 1, 3) = 257 Then   ' pwd message
       GoTo skip
       End If
       If Mid(tmps, 1, 3) = 221 Then   ' closing message
       GoTo skip
       End If
       ServerLog.AddItem tre
skip:
       Else
       If Left(tmps, 3) = "220" Then
       ' Server Welcome Message
           If InStr(1, Mid(tmps, 5, leng), vbCrLf) Then
           tre = vbCrLf & tre ' add one to beginning
           MessCnt = CountStr(tre, " ")
           If MessCnt = 0 Then Exit Sub
           ret = Parse2Array(tre, tmpArray(), vbCrLf)
           For t = 1 To MessCnt
           ServerLog.AddItem Mid(tmpArray(t), 2, Len(tmpArray(t)))
           If Mid(Mid(tmpArray(t), 2, Len(tmpArray(t))), 1, 10) = "220-Serv-U" Then ' SERV-U sends different path than War-ftp, mine is also compatable to war...,  go figure!
           servu = True
           End If
           Next
           Else
           ServerLog.AddItem tre
           End If
           End If
       End If
       
       If state < 5 Then
       If chgDirLc.Text <> "" Then
       ChDir chgDirLc.Text
       End If
       If state = 3 Then
       Doing_list = True
       Unload FTPLogin
       End If
           If Left(tmps, 3) = States(state).BackCode Then
           Label3.ForeColor = &HFFFFFF
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           bReplied = True
               con.SendData States(state).Command + Chr(13) + Chr(10)
               Debug.Print States(state).Command + Chr(13) + Chr(10)
               state = state + 1
               Exit Sub
           Else
           End If
           End If
           
           If Left(tmps, 4) = "LIST" Then
           Doing_list = True
           End If
           
           If Left(tmps, 4) = "150 " Then
           If InStr(1, tmps, "/bin/ls.") Then
           GoTo skipper
           End If
               If Doing_Download = True Then
               client.total_size = Val(Right(tmps, Len(tmps) - InStr(tmps, "(")))
               open_file (RemoteFiles.Text)
               End If
               Exit Sub
skipper:
           End If
           
           
           If Left(tmps, 4) = "214 " Then
           ServerLog.AddItem "214 Help:"
           ServerLog.AddItem tre
           End If
           
           
           If Left(tmps, 4) = "221 " Then
           ServerLog.AddItem "Socket Closed"
           ServerLog.AddItem Mid(tmps, 1, Len(tmps) - 2)
           state = 0
           Do Until con.state <> sckConnected
           Call Wait(0.1)
           Loop
           con.Close
           data.Close
           End If
 
           If Left(tmps, 4) = "226 " Then
           Label3.ForeColor = &HFFFFFF
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           Close #1
           Me.MousePointer = 0
           If doing_multi = False Then
           client.transferTotalBytes = 0
           trans = 0
           End If
           Progress.Position = 0
           ServerLog.AddItem "Done..."
           data.Close
           cmdCancel.Enabled = False
           
           If halt_transfer = True Then
           ServerLog.AddItem "226 Transfer aborted."
           halt_transfer = False
           Exit Sub
           End If
           
           If Doing_list = True Then
           Doing_list = False
           Exit Sub
           End If
           
           If Doing_Upload = True Then
           Doing_Upload = False
           ServerLog.AddItem "PWD"
           con.SendData "TYPE A" + Chr(13) + Chr(10)
           WaitFor (200)
           con.SendData ("PWD" + Chr(13) + Chr(10))
           'If chkSounds.Value = 1 Then
           'BeginPlaySound (103)
           'End If
           Exit Sub
           End If
           
           If Doing_Download = True Then
           'If chkSounds.Value = 1 Then
           'BeginPlaySound (103)
           'End If
           RefreshLocal
           Doing_Download = False
           End If
           End If
           
           If Left(tmps, 4) = "250 " Then
           Label3.ForeColor = &HFFFFFF
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           If doing_multi = False Then
           ServerLog.AddItem "PWD"
           con.SendData "TYPE A" + Chr(13) + Chr(10)
           WaitFor (200)
           con.SendData ("PWD" + Chr(13) + Chr(10))
           End If
           End If
           
           If Left(tmps, 4) = "257 " Then
           Main.Caption = "Doing List"
           Label3.ForeColor = &HFFFFFF
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           dir_info = ""
           
           'If chkSounds.Value = 1 Then
               'BeginPlaySound (101)
           'End If
           
           If create_dir = True Then
           create_dir = False
           GoTo jump
           End If
           
           If remove_dir = True Then
           remove_dir = False
           GoTo jump
           End If
           
           If servu = False Then
           remote_dir = Mid(tmps, 6, Len(tmps) - 30)
           RemotePWD.Text = remote_dir
           prevPath = Splitpath(remote_dir, 2)
           ServerLog.AddItem "257 " & Mid(tmps, 6, Len(tmps) - 30) & " is working directory"
           End If
           
           If servu = True Then
           If Len(tmps) <= 30 Then
           remote_dir = Mid(tmps, 6, 1)
           GoTo skiper
           End If
           
           remote_dir = Mid(tmps, 7, Len(tmps) - 30)
           ServerLog.AddItem "257 " & Mid(tmps, 6, Len(tmps) - 30) & " is working directory"
           RemotePWD.Text = remote_dir
           prevPath = Splitpath(remote_dir, 2)
           GoTo jump
skiper:
           RemotePWD.Text = remote_dir
           RemoteDirectories.AddItem Mid(tmps, 6, 1)
           ServerLog.AddItem "257 " & Mid(tmps, 6, 1) & " is working directory"
           End If
           
jump:
           Call ipeer
           con.SendData (prts + Chr(13) + Chr(10))
           Doing_list = True
           Call WaitFor(200)
           testdir = ""
           testfile = ""
           Main.RemoteDirectories.Clear
           Main.RemoteFiles.Clear
           Main.RemoteDirectories.AddItem ".."
           con.SendData ("LIST " + Chr(13) + Chr(10))
           End If
           
           If Left(tmps, 4) = "425 " Then
           Label3.ForeColor = &HFFFFFF
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           Me.MousePointer = 0
           data.Close
           con.SendData "TYPE A" + Chr(13) + Chr(10)
           WaitFor (200)
           con.SendData ("PWD " + Chr(13) + Chr(10))
           End If
           
           If Left(tmps, 4) = "426 " Then
           If chkSounds.Value = 1 Then
           BeginPlaySound (102)
           End If
           data.Close
           End If
           
           If Left(tmps, 4) = "530 " Then
           Label3.ForeColor = &HFF&
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           con.Close
           state = 8
           If chkSounds.Value = 1 Then
           BeginPlaySound (102)
           End If
           End If
           
           If Left(tmps, 4) = "550 " Then
           If chkSounds.Value = 1 Then
           BeginPlaySound (102)
           End If
           Label3.ForeColor = &HFF&
           Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
           Me.MousePointer = 0
           
           If Doing_list = True Then
           Doing_list = False
           data.Close
           Exit Sub
           End If
           
           If Doing_Download = True Then
           Doing_Download = False
           Close #1
           data.Close
           If multiMove.Visible = True Then
           Unload multiMove
           End If
           Exit Sub
           End If
           
           If Doing_Upload = True Then
           Close #10
           Doing_Upload = False
           data.Close
           If multiMove.Visible = True Then
           Unload multiMove
           End If
           Exit Sub
           End If
           
           If remove_dir = True Then
           remove_dir = False
           Exit Sub
           End If
           data.Close
           Me.MousePointer = 0
           End If
           
           
           

End Sub

Private Sub Coolbar_Click(Index As Integer)
Dim II, size As Long, si As Long, nam As Long
Dim w As Integer
Dim r As Integer
r = Index


Select Case r
Case "0"
If isit = True Then
Beep
GoTo skipper
End If
FTPLogin.Show
skipper:

Case "1"
Call Disconnect
FTPLogin.OK.Enabled = True
FTPLogin.Cancel.Enabled = True
testdir = ""
testfile = ""

Case "2"
On Error GoTo getout
If RemoteFiles.SelCount = 0 Then
Beep
Exit Sub
End If

Main.Caption = "Doing Download"
numberof = 1
trans = 0
client.transferTotalBytes = 0
halt_transfer = False

If RemoteFiles.SelCount = 1 Then
doing_multi = False
Doing_Download = True
restr = " " & RemoteFiles.Text
client.total_size = Parse(restr, 2)
Progress.Max = client.total_size
restr = Parse(restr, 1)
client.File_Name = restr
ServerLog.AddItem "Receiving " & restr & " as " & restr & " (1 of 1)"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "RETR " & restr + Chr(13) + Chr(10)

ElseIf RemoteFiles.SelCount > 1 Then
For II = 0 To RemoteFiles.ListCount - 1
si = 0
If RemoteFiles.Selected(II) Then
restr = " " & RemoteFiles.List(II)
si = Parse(restr, 2)
si = si / 100
size = size + si
End If
Next
multiMove.ProgressBar1.Max = size

doing_multi = True

    For II = 0 To RemoteFiles.ListCount - 1
    Doing_Download = True
        If RemoteFiles.Selected(II) Then
        restr = " " & RemoteFiles.List(II)
        client.total_size = Parse(restr, 2)
        restr = Parse(restr, 1)
        client.File_Name = restr
        multiMove.lblNumber = "Moving " & numberof & " of " & RemoteFiles.SelCount & " Files"
        multiMove.lblInfo = "Receiving File: " & restr & "  " & client.total_size & " Bytes"
        multiMove.Show
        ServerLog.AddItem "Receiving " & restr & " as " & restr & "(" & numberof & " of " & RemoteFiles.SelCount & ")"
        con.SendData "TYPE I" + Chr(13) + Chr(10)
        Call ipeer
        WaitFor (200)
        con.SendData prts + Chr(13) + Chr(10)
        WaitFor (200)
        con.SendData "RETR " & restr + Chr(13) + Chr(10)
        WaitFor (226)
        numberof = numberof + 1
        Call Wait(0.25)
        End If
    Next II
    multiMove.lblNumber = "Transfer Complete"
    multiMove.lblInfo = ""
doing_multi = False
size = 0
Call Wait(0.75)
Unload multiMove
RefreshLocal
End If
Exit Sub

getout:
data.Close
Doing_Download = False
doing_multi = False

Case "3"
If LocalFiles.SelCount = 0 Then
Beep
Exit Sub
End If

Main.Caption = "Doing Upload"
numberof = 1
trans = 0
halt_transfer = False
dir_info = ""
client.transferTotalBytes = 0
Dim inn As Integer
inn = LocalFiles.SelCount

If inn = 1 Then
doing_multi = False
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If

Open (Local_Dir & LocalFiles.Text) For Binary As #10
With client
.total_size = 0
.transferBytesSent = 0
.currentFile = LocalFiles.Text
End With

Doing_Upload = True
  con.SendData "TYPE I" + Chr(13) + Chr(10)
  Call ipeer
  WaitFor (200)
  con.SendData prts + Chr(13) + Chr(10)
  WaitFor (200)
  con.SendData "STOR " & LocalFiles.Text + Chr(13) + Chr(10)
  WaitFor (150)
  SendFile
 
  ElseIf LocalFiles.SelCount > 1 Then
 
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If

For II = 0 To LocalFiles.ListCount - 1
si = 0
If LocalFiles.Selected(II) Then
Open Local_Dir & LocalFiles.List(II) For Random As #3
si = LOF(3)
Close #3

si = si / 100
size = size + si
End If
Next

multiMove.ProgressBar1.Max = size
doing_multi = True
 
    For II = 0 To LocalFiles.ListCount - 1
    Doing_Upload = True
        If LocalFiles.Selected(II) Then
        restr = LocalFiles.List(II)
        client.File_Name = restr
        If Right(Local_Dir, 2) = "\\" Then
        Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
        End If
        Open (Local_Dir & restr) For Binary As #10
        nam = LOF(10)
        multiMove.lblNumber = "Moving " & numberof & " of " & LocalFiles.SelCount & " Files"
        multiMove.lblInfo = "Sending File: " & restr & "  " & nam & " Bytes"
        multiMove.Show
        ServerLog.AddItem "Sending " & restr & " as " & restr & " (" & numberof & " of " & inn & ")"
        con.SendData "TYPE I" + Chr(13) + Chr(10)
        Call ipeer
        WaitFor (200)
        con.SendData prts + Chr(13) + Chr(10)
        WaitFor (200)
         con.SendData "STOR " & restr + Chr(13) + Chr(10)
         WaitFor (150)
         SendFile
         WaitFor (226)
         numberof = numberof + 1
         Call Wait(0.25)
        End If
    Next II
 
  End If
 
multiMove.lblNumber = "Transfer Complete"
multiMove.lblInfo = ""
multiMove.ProgressBar1.Position = 0
doing_multi = False
size = 0
Call Wait(0.75)
Unload multiMove
RefreshLocal

Case "4"
AboutBox.Show

Case "5"
RemotePWD.Text = ""
Call Disconnect
Call Wait(0.75)
Me.Hide
Call Wait(1)
End

End Select

End Sub

Private Sub Coolbar_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonDown (Index)
End Sub

Private Sub Coolbar_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveMouse (Index)
End Sub

Private Sub Coolbar_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonUp (Index)
End Sub

Private Sub CoolBarImage_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonDown (Index)
End Sub

Private Sub CoolBarImage_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveMouse (Index)
End Sub

Private Sub CoolBarImage_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonUp (Index)
End Sub

Private Sub data_Close()
Close #1
    data.Close
    Me.MousePointer = 0
    Progress.Position = 0
    Main.Caption = "Connected to " & con.RemoteHostIP
End Sub

Private Sub data_ConnectionRequest(ByVal requestID As Long)
data.Close
data.Accept requestID
End Sub

Private Sub data_DataArrival(ByVal bytesTotal As Long)
Dim k As Integer
cmdCancel.Enabled = True
On Error Resume Next
data.GetData rmdata, , bytesTotal
trans = trans + bytesTotal
client.transferTotalBytes = trans

If doing_multi = False Then
Progress.Position = trans
Else
multiMove.ProgressBar1.Position = (trans / 100)
End If

If Doing_list = True Then
Do Until Response = "226"
dir_info = dir_info & rmdata
Call Wait(0.1)
Loop

Dirlist (dir_info)
Call Wait(0.1)
RemoteDirectories.Refresh
Exit Sub
End If


Put #1, , rmdata

End Sub

Private Sub data_SendComplete()
With client
                If .total_size = .transferBytesSent Then
                    Close #10
                    data.Close
                    .transferBytesSent = 0
                    'If doing_multi = False Then
                    Progress.Position = 0
                    cmdCancel.Enabled = False
                Else
                    SendFile
                End If
    End With

End Sub

Private Sub Drive1_Change()
ChDrive Drive1.Drive
RefreshLocal
End Sub

Private Sub Form_Activate()
If Main.Caption = "Not Connected" Then
GoTo skip
End If
    If FirstTime = False Then
       FirstTime = True
       DoEvents
       RefreshAll
    End If
skip:
End Sub

Private Sub Form_Load()
App.HelpFile = (App.Path & "\" & "ez-ftp.hlp")
akm = 0
    Dim test As Boolean
    Me.Move (Screen.Width \ 2) - (Me.Width \ 2), (Screen.Height \ 2) - (Me.Height \ 2)
    FirstTime = False
    bReplied = False
    Cann = False
    Doing_list = False
    halt_transfer = False
    create_dir = False
    remove_dir = False
    servu = False
    loadSaved
    Call FormEffect(Main, 144, 135, 60, True, True)
    Timer1.Enabled = True
End Sub


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If x1 >= Me.Width - 485 And x1 <= Me.Width - 300 And y1 >= 75 And y1 <= 255 Then
        Me.WindowState = 1
    End If
    If x1 >= Me.Width - 275 And x1 <= Me.Width - 90 And y1 >= 75 And y1 <= 255 Then
   RemotePWD.Text = ""
Call Disconnect
Call Wait(0.75)
Me.Hide
Call Wait(1)
End
End If
Dim ReturnVal As Long
                     X = ReleaseCapture()
                     ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
    x1 = X
    y1 = Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub

Private Sub Form_Resize()
If Me.WindowState = 1 Then Exit Sub
Me.Width = 7290
Me.Height = 7350
End Sub

Private Sub Form_Unload(Cancel As Integer)
Close #1
    Me.Hide
    If con.state = sckConnected Then
    Call Disconnect
    Else
    con.Close
    data.Close
    End If
    Call Wait(0.75)
    Dim Dummy As String
vHelp& = WinHelp(Main.hWnd, Dummy, HELP_QUIT, 0)
    End
End Sub

Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Frame2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Frame3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Local_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
                     X = ReleaseCapture()
                     ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub

Private Sub Local_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Local_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub

Private Sub LocalCD_Click()

Dim NewDirectory As String

    NewDirectory = InputBox$("Enter directory to change to")
    If NewDirectory = "" Then
        Exit Sub
    End If

    On Error Resume Next
    ChDir NewDirectory
    If Err <> 0 Then
        MsgBox "Unable to change directory", vbExclamation: DoEvents
    Else
        RefreshLocal
    End If
   
End Sub

Private Sub LocalDEL_Click()
Dim ret As Boolean
If LocalFiles.SelCount > 1 Then
Call delem
Exit Sub
End If

ret = ShellDelete(Local_Dir & LocalFiles.Text, FOF_ALLOWUNDO, "")
RefreshLocal
End Sub

Private Sub LocalDirectories_DblClick()
    If LocalDirectories.ListIndex = -1 Then
        Beep
        Exit Sub
    End If
    doing_multi = False
    ChDir LocalDirectories.Text
    RefreshLocal
   
End Sub


Private Sub LocalDirectories_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub LocalDirectories_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RemoteFiles.ListIndex = -1
End Sub

Private Sub LocalFiles_DblClick()
If con.state <> sckConnected Then Exit Sub
On Error GoTo airr
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
Open (Local_Dir & LocalFiles.Text) For Binary As #10
doing_multi = False
With client
.total_size = 0
.transferBytesSent = 0
.currentFile = LocalFiles.Text
End With
Doing_Upload = True
  con.SendData "TYPE I" + Chr(13) + Chr(10)
  Call ipeer
  WaitFor (200)
  con.SendData prts + Chr(13) + Chr(10)
  WaitFor (200)
  con.SendData "STOR " & LocalFiles.Text + Chr(13) + Chr(10)
  WaitFor (150)
  SendFile
  Exit Sub
airr:
  If Err.Number = 40006 Then
 MsgBox "       Not Connected          ": DoEvents
Else
MsgBox "There was an Error - #" & Err.Number: DoEvents
End If
Close #10
End Sub


Private Sub LocalFiles_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub

Private Sub LocalFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub LocalMD_Click()

Dim NewDirectory As String
   
    NewDirectory = InputBox$("Enter new directory name")
    If NewDirectory = "" Then
        Exit Sub
    End If
   
    On Error Resume Next
    MkDir NewDirectory
    If Err <> 0 Then
        MsgBox "Unable to make local directory", vbExclamation: DoEvents
    Else
        RefreshLocal
    End If

End Sub

Private Sub LocalRD_Click()
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Remove Directory from Local System?", _
    vbOKCancel + vbQuestion, "Remove Directory"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo bherr
End If
    If LocalDirectories.ListIndex = -1 Then
        Beep
        Exit Sub
    End If
   
    On Error Resume Next
    RmDir LocalDirectories.Text
    If Err <> 0 Then
        MsgBox "Unable to remove local directory", vbExclamation: DoEvents
    Else
        RefreshLocal
    End If
bherr:
End Sub

Private Sub OptFrame_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Remote_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
                     X = ReleaseCapture()
                     ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub

Private Sub Remote_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub Remote_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub

Private Sub RemoteCD_Click()
On Error GoTo cherr
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Change Directory on Server?", _
    vbOKCancel + vbQuestion, "Change Directory"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo cherr
End If
Dim NewDirectory As String

    NewDirectory = InputBox$("Enter directory to change to")
    If NewDirectory = "" Then
        Exit Sub
    End If
    If con.state = sckConnected Then
    con.SendData ("CWD " & NewDirectory & " " & Chr(13) + Chr(10))
    End If

cherr:
End Sub

Private Sub RemoteDEL_Click()
If RemoteFiles.SelCount > 1 Then
doing_multi = True
Call sdelem
Exit Sub
End If

Dim ans As Integer
Dim Cancel As Boolean

If RemoteFiles.ListIndex = -1 Then
MsgBox "You Must Select a File on the Server First!": DoEvents
Exit Sub
End If

doing_multi = False

Dim str1 As String, str2 As String
dir_info = ""
str1 = " " & RemoteFiles.Text


str2 = Parse(str1, 2)
str1 = Parse(str1, 1)

ans = MsgBox("Delete " & str1 & " - " & str2 & " bytes," & " from Server?", _
    vbOKCancel + vbQuestion, "Delete File"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo herr
End If
If con.state = sckConnected Then
Main.Caption = "Doing Delete"
con.SendData "DELE " & str1 + Chr(13) + Chr(10)
End If
   
herr:
End Sub

Private Sub RemoteDirectories_DblClick()
On Error Resume Next
If con.state <> sckConnected Then Exit Sub
If RemoteDirectories.Text = remote_dir Then Exit Sub
doing_multi = False
Doing_list = True
'MsgBox remote_dir

If RemoteDirectories = ".." Then
Doing_list = True
RemoteFiles.Clear
RemoteDirectories.Clear
con.SendData ("CDUP " + Chr(13) + Chr(10))
Exit Sub
End If

Me.MousePointer = 11
If Mid(RemoteDirectories.Text, 1, 1) = " " Then
remote_dir = Mid(RemoteDirectories.Text, 2, Len(RemoteDirectories.Text) - 1)
Else
remote_dir = RemoteDirectories.Text
End If
    On Error Resume Next
    con.SendData ("CWD " + remote_dir + Chr(13) + Chr(10))
   
   
    If Err <> 0 Then
        MsgBox "Unable to change directory", vbExclamation: DoEvents
    Else
        RefreshRemote
    End If
   
End Sub


Private Sub RemoteDirectories_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub RemoteFiles_DblClick()
If con.state <> sckConnected Then Exit Sub
Me.MousePointer = 11
Doing_Download = True
doing_multi = False
restr = " " & RemoteFiles.Text
client.total_size = Parse(restr, 2)
Progress.Max = client.total_size
restr = Parse(restr, 1)
client.File_Name = restr
ServerLog.AddItem "Receiving " & restr & " as " & restr & " (1 of 1)"
Main.Caption = "Doing Download"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "RETR " & restr + Chr(13) + Chr(10)
End Sub


Private Sub RemoteFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Coolbar(PrevButton).BorderStyle = 0
    CoolBarImage(PrevButton).Visible = True
    PrevButton = -1
End Sub

Private Sub RemoteFiles_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub

Private Sub RemoteMD_Click()
On Error GoTo gherr
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Create Directory on Server?", _
    vbOKCancel + vbQuestion, "Create Directory"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo gherr
End If
Dim NewDirectory As String
   
    NewDirectory = InputBox$("Enter new directory name"): DoEvents
    If NewDirectory = "" Then
        Exit Sub
    End If
    create_dir = True
    If con.state = sckConnected Then
    con.SendData ("MKD " + NewDirectory + Chr(13) + Chr(10))
    End If
   
 Exit Sub
gherr:

End Sub

Private Sub RemotePWD_KeyPress(KeyAscii As Integer)
Dim patlen As Integer, truth As String
On Error GoTo bott
If KeyAscii = 13 Then
patlen = Len(remote_dir)
truth = RemotePWD.Text
dir_info = ""
If con.state = sckConnected Then
con.SendData ("CWD " + truth + Chr(13) + Chr(10))
End If
KeyAscii = 0
End If
Exit Sub

bott:
On Error Resume Next
con.SendData ("CDUP " + Chr(13) + Chr(10))
KeyAscii = 0
End Sub

Private Sub RemoteRD_Click()
On Error GoTo aherr
Dim shrt As String
Dim ans As Integer
Dim Cancel As Boolean
 If RemoteDirectories.SelCount = 0 Then
        MsgBox "You Must Select a Directory on Server First": DoEvents
        Exit Sub
    End If
 shrt = RemoteDirectories.Text
   
 If Mid(shrt, 1, 1) = " " Then
 shrt = Mid(shrt, 2, Len(shrt) - 1)
 End If
 
ans = MsgBox("Remove Directory " & shrt & " from Server?", _
    vbOKCancel + vbQuestion, "Remove Directory"): DoEvents
If ans = vbOK Then
    Cancel = False
Else

    Cancel = True
    GoTo aherr
End If
remove_dir = True
If con.state = sckConnected Then
con.SendData ("RMD " & shrt + Chr(13) + Chr(10))
End If
 Exit Sub
   
aherr:
End Sub

Private Sub Timer1_Timer()
lblTime.Caption = Time
End Sub

Private Sub Title_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ReturnVal As Long
                     X = ReleaseCapture()
                     ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub

Private Sub UseMask_Click()
If UseMask.Value = 1 Then
chkLc.Enabled = True
chkRm.Enabled = True
Local_mask.Enabled = True
Remote_mask.Enabled = True
Else
chkLc.Enabled = False
chkRm.Enabled = False
Local_mask.Enabled = False
Remote_mask.Enabled = False
End If
End Sub

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2001-02-11 at 16:22:43ID20076077
Topic

Visual Basic Programming

Participating Experts
4
Points
300
Comments
11

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. strange ret?
    Dear guys, Another unrelated question... In an assembly program, What are the likely causes of a ret that jumps to a strange place after the return? The memory model is large which seems okay. like this.... sub_123 proc far : : ret sub_123 endp the re...
  2. w2k & war-ftp - help needed
    I have w2k up and running now. I also have war-ftp running. However whenever someone tries to connect, they can't. I can connetc locally but they can't connect at all. I only allow registered users to connect. Do I have to create all of these users in w2k as well as the ft...
  3. FTP download
    I have a prog.exe for downloading. There is no problem using a HTTP download . What about firewall if the company is behind it. Cud someone teach me how to set up the page for FTP downlaod? normally we see something like ftp.mycon.com.. how do I do that?
  4. Advance Wars 2 Blackhole rising guide for Showstopper
    Please may someone give me a S-rank guide for Advance Wars 2 BlackHole rising map showstopper.
  5. RET instruction
    win32 api, at the end of a function (specifically a dialog procedure returning 0) the code is xor eax,eax leave ret 16 what happens if you omit the 16 from the ret?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mammouthPosted on 2001-02-12 at 13:42:56ID: 5836235

Explanation of some ftp function i will explain you the code tonight

Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean

7 hConnect
[in] Valid HINTERNET handle returned by a previous call to InternetConnect using INTERNET_SERVICE_FTP.

7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to create on the remote system. This can be either a fully qualified path or a name relative to the current directory.





Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean

7 hConnect
[in] Valid HINTERNET handle returned by a previous call to InternetConnect using INTERNET_SERVICE_FTP.

7 lpszFileName
[in] Address of a null-terminated string that contains the name of the file to delete on the remote system.



Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long
7 hConnect
[in] Valid handle to an FTP session returned from InternetConnect.

7 lpszSearchFile
[in] Address of a null-terminated string that specifies a valid directory path or file name for the FTP server's file system. The string can contain wildcards, but no blank spaces are allowed. If the value of lpszSearchFile is NULL or if it is an empty string, it will find the first file in the current directory on the server.

7 lpFindFileData
[out] Address of a WIN32_FIND_DATA structure that receives information about the found file or directory.

7 dwFlags
[in] Unsigned long integer value that contains the flags that control the behavior of this function. This can be a combination of the following values:
INTERNET_FLAG_HYPERLINK
INTERNET_FLAG_NEED_FILE
INTERNET_FLAG_NO_CACHE_WRITE
INTERNET_FLAG_RELOAD
INTERNET_FLAG_RESYNCHRONIZE

7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This parameter is used only if the application has already called InternetSetStatusCallback to set up a status callback function.






Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long

7 hConnect
[in] Valid handle to an FTP session.

7 lpszCurrentDirectory
[out] Address of a buffer that receives the current directory string, which specifies the absolute path to the current directory. The string is null-terminated.

7 lpdwCurrentDirectory
[in, out] Address of a variable that specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating NULL character. Using a length of MAX_PATH is sufficient for all paths. When the function returns, the variable receives the number of characters copied into the buffer.






Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean

7 hConnect
[in] Valid handle to an FTP session.

7 lpszRemoteFile
[in] Address of a null-terminated string that contains the name of the file to retrieve from the remote system.

7 lpszNewFile
[in] Address of a null-terminated string that contains the name of the file to create on the local system.

7 fFailIfExists
[in] BOOL that indicates whether the function should proceed if a local file of the specified name already exists. If fFailIfExists is TRUE and the local file exists, FtpGetFile fails.

7 dwFlagsAndAttributes
[in] Unsigned long integer value that contains the file attributes for the new file. This can be any combination of the FILE_ATTRIBUTE_* flags used by the CreateFile  function. For more information on FILE_ATTRIBUTE_* attributes, see CreateFile in the Platform SDK.

7 dwFlags
[in] Unsigned long integer value that contains the flags that control how the function will handle the file download. The first set of flag values indicates the conditions under which the transfer occurs. These transfer type flags can be used in combination with the second set of flags that control caching.
The application can select one of these transfer type values:
FTP_TRANSFER_TYPE_ASCII
 Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
FTP_TRANSFER_TYPE_BINARY
 Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
FTP_TRANSFER_TYPE_UNKNOWN
 Defaults to FTP_TRANSFER_TYPE_BINARY.
INTERNET_FLAG_TRANSFER_ASCII
 Transfers the file as ASCII.
INTERNET_FLAG_TRANSFER_BINARY
 Transfers the file as binary.
The following flags determine how the caching of this file will be done. Any combination of the following flags can be used with the transfer type flag. The possible values are:

INTERNET_FLAG_HYPERLINK
 Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
INTERNET_FLAG_NEED_FILE
 Causes a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_RELOAD
 Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZE
 Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.

7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This is used only if the application has already called InternetSetStatusCallback to set up a status callback function.
 








Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

7 hConnect
[in] Valid HINTERNET handle to an FTP session.

7 lpszLocalFile
[in] Address of a null-terminated string that contains the name of the file to send from the local system.

7 lpszNewRemoteFile
[in] Address of a null-terminated string that contains the name of the file to create on the remote system.

7 dwFlags
[in] Unsigned long integer value that contains the conditions under which the transfers occur. The application should select one transfer type and any of the flags that control how the caching of the file will be controlled.
The transfer type can be any one of the following values:
FTP_TRANSFER_TYPE_ASCII
 Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
FTP_TRANSFER_TYPE_BINARY
 Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
FTP_TRANSFER_TYPE_UNKNOWN
 Defaults to FTP_TRANSFER_TYPE_BINARY.
INTERNET_FLAG_TRANSFER_ASCII
 Transfers the file as ASCII.
INTERNET_FLAG_TRANSFER_BINARY
 Transfers the file as binary.
The following values are used to control the caching of the file. The application can use one or more of the following values:

INTERNET_FLAG_HYPERLINK
 Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
INTERNET_FLAG_NEED_FILE
 Causes a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_RELOAD
 Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZE
 Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.

7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This parameter is used only if the application has already called InternetSetStatusCallback to set up a status callback.




Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean

7 hConnect
[in] Valid HINTERNET handle to an FTP session.

7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to remove on the remote system. This can be either a fully qualified path or a name relative to the current directory.





Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean

7 hConnect
[in] Valid HINTERNET handle to an FTP session.

7 lpszExisting
[in] Address of a null-terminated string that contains the name of the file that will have its name changed on the remote FTP server.

7 lpszNew
[in] Address of a null-terminated string that contains the new name for the remote file.


Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean


7 hConnect
[in] Valid HINTERNET handle to an FTP session.

7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to change to on the remote system. This can be either a fully qualified path or a name relative to the current directory.

 

by: mammouthPosted on 2001-02-13 at 05:14:03ID: 5838283

Here is the easyeast way to do a ftp you can find explanation for this Function in me first comment

Put this in a module
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Public Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer

Put this in a form

Dim Port as integer
Dim Ip as string
Dim UserName as string
Dim Password as string
Dim SourceFile as string
Dim DestinationFile as string

Ip="123.123.123.123"
Port=21
UserName="Test"
Password="Test"
SourceFile="test.gif"
DestinationFile="test.gif"

hOpen = InternetOpen("vb wininet", 1, vbNullString, vbNullString, 0)
hConnection = InternetConnect(hOpen, Ip, Port, UserName, Password, 1, &H8000000, 0)
DoConnection = hConnection
If DoConnection Then
     bret = FtpPutFile(hConnection, SourceFile, DestinationFile, 0, 0)     'Put a file
     bret = FtpGetFile(hConnection, DestinationFile, SourceFile, False, INTERNET_FLAG_RELOAD, dwType, 0) 'Get a file

     InternetCloseHandle (hConnection)     'Close the connection
Else
     debug.print "Connection Failed"
End If

 

by: mammouthPosted on 2001-02-13 at 05:15:25ID: 5838289

Scuse but
INTERNET_FLAG_RELOAD = &H10000

 

by: sjaguar13Posted on 2001-02-16 at 20:18:42ID: 5851592

Ok, I can connect now, but how to I list the files and directories on both computers and how do I have it download files?

 

by: sjaguar13Posted on 2001-03-16 at 16:28:53ID: 5936439

I'm still confused

 

by: MoondancerPosted on 2001-12-25 at 16:20:41ID: 6693913

Open today, please update/finalize this.

Thanks,

Moondancer
Community Support Moderator @ Experts Exchange

 

by: JanusFuryPosted on 2001-12-27 at 16:29:24ID: 6697596

Why on earth is this topic SO BIG?

Perhaps you need to read the FTP RFC, which describes the FTP protocol in detail.

 

by: MoondancerPosted on 2001-12-31 at 11:05:54ID: 6702821

sjaguar13 --->  You've asked a total of 24 questions and only closed/graded 10 of them.  Some are more than ONE YEAR old, this is unacceptable.  Please click the HELP DESK link on the left which contains our Guidelines and Agreement as well as information on site-related help files on questions and answers.

I will update all your open questions with this information so that you will be advised by Email notification and can navigate through them to finalize them.

Your responsiveness is needed on all of them.  I will monitor for closure.  If you need help in terms of splitting points between participants or other related assistance, please comment with details and I will return as quickly as I can.

Thank you,
Moondancer
Community Support Moderator @ Experts Exchange

 

by: MoondancerPosted on 2002-01-01 at 14:59:16ID: 6704206

If you've been helped here, please accept the comment which best served you to grade and close this item.  If more is needed, please provide feedback in that regard.  If you wish to award more than one, just comment with details and I'll handle for you.

Thank you,
Moondancer
Community Support Moderator @ Experts Exchange

 

by: ericpetePosted on 2002-01-03 at 21:04:54ID: 6709475

This question appears to have been abandoned. A question regarding will be left in the Community Support area regarding its disposition; if you have any comment about the question, please leave it here, as Moondancer is watching this question.

Unless there is objection or further activity, one of the moderators will be asked to accept the comment of mammouth.

The link to the Community Support area is:
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

DO NOT ACCEPT THIS COMMENT AS AN ANSWER.

Regards,

ep

 

by: MoondancerPosted on 2002-01-04 at 04:44:10ID: 6710056

I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
 

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...