Delete file from Server

Pierre K
Pierre K used Ask the Experts™
on
Hi all,
I'm using WPut and WGet to upload and download files to a FTP Server but need some Access VBA code to delete a file from there please.
Maybe some FTP Shell command?

Thanks
Pierre
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015

Commented:
Hi

You can use
 
delete  filename.ext
or
mdelete *.ext

Author

Commented:
@Kanti - thanks for the reply.
Could you provide more info as to how I would implement this in Access VBA please?
As explained the file I need to delete resides on my Web Server.
So I need some FTP command to delete the specific file
Top Expert 2015

Commented:
Hi

The one I gave you is to run it as a FTP command. Try it and if it works just put it as a .bat file and run it.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
@Kanti - I created a bat file with ref to the http path to the file but I'm getting an error stating that the 'delete' or 'mdelete' command doesn't exist
Top Expert 2015

Commented:
Hi

Initially run just with the delete  on that server then we can look giving the path name.

FTP> prompt
FTP> delete filename*.ext  |yes

Author

Commented:
@Kanti - OK I understand but I need the full code to login and do the delete from within VBA code.
I have an idea how to do it via Command Prompt but not sure how to do it all the way with VBA code.
Sorry - hope that make sense?
Top Expert 2015

Commented:
Hi

Just record a macro in xls and copy this

Sub macro()
Kill "C:\yourdirectorypath\*.ext"
End Sub
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
There is no WDel for Windows, but you can run a script for the FTP utility:

WDel.cmd
@echo off
>file.txt echo open ftp.mysite.com
>>file.txt echo username
>>file.txt echo password
>>file.txt echo cd  /directory
>>file.txt echo binary
>>file.txt echo del %1
>>file.txt echo disconnect
>>file.txt echo bye

ftp -i -s:"file.txt"
del "file.txt"

Open in new window

/gustav

Author

Commented:
@Gustav - Ahhh - that sounds far more like the code I need.
I would only be able to test it in the morning (our time).
Only need to figure out how to put it in a Function or VBA script - would be nice if you could help with that...
Thanks
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Here's an example:

Upload file via FTP from VBA

/gustav

Author

Commented:
@Gustav - Thanks a lot - worked like a dream!
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

/gustav

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial