我做的可上传下载控件,欢迎使用。

80酷酷网    80kuku.com

  控件|上传|下载|下载控件这是控件的源程序:
工程名:MY
控件名:TESTFTP

Dim FileName As String
Dim connect As Boolean


Private Sub CmdCd_Click()

  Call Link
  'Inet1.Execute , "cd c2000"
  connect = True
   
End Sub

Private Sub CmdList_Click()

  If connect = True Then
    Inet1.Execute , "LS"
  Else
    Label1.Caption = "please click connect first!"
  End If

End Sub


Private Sub Combo1_Click()
  
  FileName = Combo1.Text 'file name of download file

End Sub

Private Sub CmdDown_Click()

  Dim FileLast As String 'last name of file
  Dim SaveFileName As String 'file name in ftpserver
  Call Link
  
  If FileName = "" Then
    Label1.Caption = "please select file to download!"
  Else
    FileLast = ""
    For i = 1 To Len(FileName)
      If Mid(FileName, i, 1) <> "." Then
        FileLast = FileLast + Mid(FileName, i, 1)
      Else
        FileLast = ""
      End If
    Next
REDO:     CommonDialog1.ShowSave

    If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
      Label1.Caption = "The file can't include space!"
      MyVar = MsgBox("Redo it?", 65, "Download file")
      If MyVar = "1" Then
        GoTo REDO:
      Else
        GoTo NODO:
      End If
    End If
    
    SaveFileName = CommonDialog1.FileName & "." & FileLast
    Inet1.Execute , "GET " & FileName & " " & SaveFileName
  End If
NODO:

End Sub

Private Sub CmdUpload_Click()
  
  Dim SaveFileName As String
  Dim UpFileName As String 'file name of upload file include path
  Dim MyVar
  SaveFileName = ""
  Call Link
  
REDO:  CommonDialog1.ShowOpen

  If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
    MsgBox "The file can't include space!"
    MyVar = MsgBox("Redo it?", 65, "Upload file")
    If MyVar = "1" Then
      GoTo REDO:
    Else
      GoTo NODO:
    End If
  End If
  
  UpFileName = CommonDialog1.FileName
  'MsgBox UpFileName
  
  For i = 1 To Len(UpFileName)
    If Mid(UpFileName, i, 1) <> "\" Then
      SaveFileName = SaveFileName + Mid(UpFileName, i, 1)
    Else
      SaveFileName = ""
    End If
  Next
  
  If SaveFileName = "" Then
    Label1.Caption = "no file!"
  Else
    Inet1.Execute , "PUT " & UpFileName & " " & SaveFileName
  End If
NODO:
   
End Sub




Private Sub Inet1_StateChanged(ByVal State As Integer)
  
   Select Case State
     Case 1
       Label1.Caption = "正在查询所指定的主机的 IP 地址"
     Case 2
       Label1.Caption = "成功地找到所指定的主机的 IP 地址。"

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: