Freshman
Registered User.
- Local time
- Today, 09:32
- Joined
- May 21, 2010
- Messages
- 437
Hi all,
I've been using WGet.exe and WPut.exe for many years but I always wished there was a similar function to delete files like “WDel.exe”
Not having much experience in functions I decided to try my hand at it but would like to some input on my logic please.
I hard-coded my domain name and user details since I will always be addressing the same domain. I guess you could also add those in the function to make it more flexible but then there is also a lot of duplication by having to type in the same old info each time. I wanted it plain and simple.
I've been using WGet.exe and WPut.exe for many years but I always wished there was a similar function to delete files like “WDel.exe”
Not having much experience in functions I decided to try my hand at it but would like to some input on my logic please.
I hard-coded my domain name and user details since I will always be addressing the same domain. I guess you could also add those in the function to make it more flexible but then there is also a lot of duplication by having to type in the same old info each time. I wanted it plain and simple.
Code:
Public Function WDel(DelFilePath As String, DelFileName As String)
Dim fso As New FileSystemObject
If fso.FileExists("C:\FTPScript.txt") = True Then fso.DeleteFile ("C:\FTPScript.txt")
f = "C:\FTPScript.txt"
Open f For Output As #1
Print #1, "open ftp.my.domain.here"
Print #1, "username"
Print #1, "*******"
Print #1, "quote pasv"
Print #1, "cd " & DelFilePath
Print #1, "ascii"
Print #1, "prompt"
Print #1, "delete " & DelFileName
Print #1, "disconnect"
Print #1, "bye"
Print #1, "exit"
Close #1
Shell "C:\Windows\System32\FTP.exe -s:C:\FTPScript.txt", vbHide
Code:
Public Function TestMe()
WDel "path/path/path", "test.txt"
End Function