Hi, I need a little help with a deleting a file from a ftp server. I have the code for uploading but I can't seem to figure out how to delete a file.
this is the FTP module I'm using
and this is the code for uploading i use in the form when i click a button
all that works like a charm.
Could someone help me with a code to delete a file from the ftp server, i'm kind of stuck
thanks in advance
this is the FTP module I'm using
Code:
Public Sub UploadFileToFTPServer()
On Error GoTo ErrHandler
Dim lngRet As Long
Dim abytData() As Long
Dim lngBytesWritten As Long
Dim lngBytesRead As Long
Dim lngTotalBytesWritten As Long
Const conERR_COULD_NOT_TRANSFER_FILE = vbObjectError + 2215
Call SysCmd(acSysCmdSetStatus, "A mudar de pasta....")
Call sChangeDir(mstrDestination)
Call SysCmd(acSysCmdSetStatus, "A carregar o ficheiro. Por favor aguarde...")
lngRet = apiFTPPutFile(hSession, mstrSrcFile, mstrDestination, _
INTERNET_FLAG_TRANSFER_BINARY Or INTERNET_FLAG_NO_CACHE_WRITE, 0&)
If lngRet = 0 Then Err.Raise conERR_COULD_NOT_TRANSFER_FILE
Call SysCmd(acSysCmdSetStatus, "Pronto...")
ExitHere:
On Error Resume Next
Call SysCmd(acSysCmdClearStatus)
Exit Sub
ErrHandler:
Select Case Err.Number
Case conERR_COULD_NOT_TRANSFER_FILE:
Err.Raise conERR_COULD_NOT_TRANSFER_FILE, "FTP::UploadFileToFTPServer", _
fInetError(Err.LastDllError)
Case Else
With Err
.Raise .Number, .Source, fInetError(.LastDllError)
End With
End Select
Resume ExitHere
End Sub
Code:
Dim objFTP As FTP
Const conTARGET = "ftpserver"
Set objFTP = New FTP
With objFTP
.FtpURL = conTARGET
.SourceFile = "sourcefile"
.DestinationFile = "destination file"
.AutoCreateRemoteDir = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToFTPHost "username", "password"
.UploadFileToFTPServer
End With
Could someone help me with a code to delete a file from the ftp server, i'm kind of stuck
thanks in advance
Last edited: