Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp upload 1

Status
Not open for further replies.

nyzja

Programmer
Jan 13, 2005
31
US
Hi! I wrote the following code to upload a text file to an ftp server. The code works fine, except that if a file with the same name already exists in the folder, i get a message asking if i want to overwrite it. I could ignore the message and it'll overwrite the file anyway after 30 seconds but I would like to know how to skip that pop up and just let the file be overwritten automatically. Please help! Thanks!

Code:
On Error Resume Next

Dim MySite
Dim myPath 

Set MySite= CreateObject("CuteFTPPro.TEConnection") 

MySite.Host = "ftp://usrname:pwd@ftpsite.com/data/"
MySite.Connect

If (Cbool(MySite.IsConnected)) Then	
	
   MySite.LocalFolder = "F:\exports"

   myPath = "F:\exports\data.txt"
   MySite.Upload myPath
   
   MySite.Disconnect
   MySite.Close
   Set MySite = nothing

End If
 
nyzja,

Try this conditional. It may not be optimal construction, but that's the idea.
[tt]
if cbool(MySite.RemoteExists("data.txt")) then
MySite.RemoteRemove "data.txt"
end if
[/tt]
I deliberately hard code "data.txt", you should make it dynamic using the info you supply to the script via myPath.

You should read their user's guide?!

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top