Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete file via FTP as per FAQ 1

Status
Not open for further replies.

hovercraft

Technical User
Jun 19, 2006
236
US
Using the code that is provided in the FAQ's here for FTP'ing, how would I use the function for deleting a file on a ftp site?

would it be

Code:
FtpDeleteFile("ftp.myserver.com", "username", "pw", "TheFileNametobeDeleted")

I'm lost....
 
This is how the function is declared;
Public Declare Function FtpDeleteFile Lib "wininet.dll" _
Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _
ByVal lpszFileName As String) As Boolean

So you should have an ftp session open.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
hmmm... something like this?

Code:
Function FTPdelete(ByVal HostName As String, _
    ByVal UserName As String, _
    ByVal Password As String, _
    ByVal FileToDelete As String)

    
    
    On Error GoTo Err_Function
        
' Declare variables
Dim hConnection, hOpen, hFile  As Long ' Used For Handles

' Open Internet Connecion
hOpen = InternetOpen("FTP", 1, "", vbNullString, 0)

' Connect to FTP
hConnection = InternetConnect(hOpen, HostName, INTERNET_DEFAULT_FTP_PORT, UserName, Password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)

Call FtpDeleteFile(hConnection, FileToDelete)
End Function

Thanks for help phv!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top