可以删除FTP上文件夹里的文件吗?是什么API函数?

解决方案 »

  1.   

    在窗口中加入inet控件
    在按钮中加上
    With Inet1
       .URL = "ftp://www.abc.com"
       .UserName = "abc"
       .Password = "abc"
       .Execute ,"DELETE abc.txt"   
       .Execute ,"CLOSE" '关闭连接。
    End With
      

  2.   

    API的可用下面的
    '连接FTP
    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 FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszName As String) As Boolean
    '删除文件
    Public Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As BooleanPublic Function RemoveFTPDirectory(sDirectory As String) As Boolean
        If (FtpRemoveDirectory(hConnection, sDirectory) = False) Then
            ErrorOut Err.LastDllError, "RemoveFTPDirectory"
            RemoveFTPDirectory = False
            Exit Function
        Else
            RemoveFTPDirectory = True
        End If
    End Function
     
    Public Function DeleteFTPFile(sRemote As String) As Boolean
        If (FtpDeleteFile(hConnection, sRemote) = False) Then
            ErrorOut Err.LastDllError, "DeleteFTPFile"
            DeleteFTPFile = False
            Exit Function
        Else
            DeleteFTPFile = True
        End If
    End FunctionPublic Function OpenConnection(sServer As String, sUser As String, sPassword As String) As Boolean
        If hConnection <> 0 Then
            InternetCloseHandle hConnection
        End If
        hConnection = InternetConnect(hOpen, sServer, INTERNET_INVALID_PORT_NUMBER, sUser, sPassword, INTERNET_SERVICE_FTP, dwSeman, 0)
        If hConnection = 0 Then
            ErrorOut Err.LastDllError, "InternetConnect"
            OpenConnection = False
            Exit Function
        Else
            OpenConnection = True
        End If
    End Function