DeleteFiles

Delete file on the remote ftp server.

Syntax

DeleteFile(STRING file)

Where:

  • File is a string (example: readme.txt)
Returns

Boolean. If it returns TRUE, the function has succeeded, otherwise it means that and error was returned. When FALSE is returned, FTPObject.LastError will return the WIN32 error code.

Example

An example which uploads a file and deletes it on a remote FTPA protocol used to transfer files between network computers. server:

Function Random(N)

Random = Int(N*Rnd)

End Function

Function Main

Dim FTPobj As Object

Dim fl As Object

'configure as needed

ip = "127.0.0.1"

port = 21

mode = FALSE

username = "anonymous"

password = "test@lnss.com"

cr = Chr(13) + Chr(10)

Set fl = file.Connect("127.0.0.1")

fl.Open "testfile.txt", GENERIC_WRITE, CREATE_ALWAYS

fl.writeline("This is a testfile")

'initialise randomization

Randomize

fl.Close

'now generate a random number to be added to the filenames

For K = 1 To 10

randomnumber = randomnumber & CStr(Random(10))

Next

tempFile = "lnssFile" + randomnumber

'create a new ftp Connection

Set FTPobj=FTP.Connect (ip,21,mode,username,password)

If FTPobj.PutFile ( "testfile.txt", tempFile ) = TRUE Then

echo "File write access is available to anonymous ftp at " + ip & cr

If FTPobj.DeleteFile ( tempFile ) = TRUE Then

echo "File Delete access is available to anonymous ftp at " + ip& cr

Else

echo "File Delete access is not available. You might need to Delete files created by GFI LanGuard" & cr

End If

End If

fl.Delete("testfile.txt")

End Function