Avatar of Pierre K
Pierre K
Flag for South Africa asked on

Delete file from Server

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
Microsoft AccessVBA

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
Kanti Prasad

Hi

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

ASKER
@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
Kanti Prasad

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Pierre K

ASKER
@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
Kanti Prasad

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
Pierre K

ASKER
@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?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Kanti Prasad

Hi

Just record a macro in xls and copy this

Sub macro()
Kill "C:\yourdirectorypath\*.ext"
End Sub
Gustav Brock

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
Pierre K

ASKER
@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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Pierre K

ASKER
@Gustav - Thanks a lot - worked like a dream!
Gustav Brock

You are welcome!

/gustav