Visual Basic and FTP

I am needing to write a VB app that will send a simple text file to a directory on our web site.  I am needing to do this through FTP and the site does require a User Name and password.  Right now we use an FTP program to connect to the site and use it to upload files to a chosen directory.   I am wanting to automate this process of uploading.  These text files are used by cgi scripts to build parts of the web pages.  I simply have no experience automating FTP
LVL 4
abaldwinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

abaldwinAuthor Commented:
Am rejecting the answer to allow for other posts.  I have downloaded the files from the URL's you posted and will examine them to see how they fit.

Of course if that gets me to the point I need to be at I will accept the answer.  Thank you for the quick response.
0
mcriderCommented:
You can use the Microsoft Internet Transfer Control (MSINET.OCX) to FTP program...

See the EXECUTE method help pages of the control for more information...


Basically it works like this:

The following will send the file "c:\autoexec.bat" to the host "caas.com".  The remote file will be called "testfile" and will be put in the  directory called "incoming":

    Inet1.URL = "ftp://caas.com" 'CHANGE caas.com TO REMOTE HOSTNAME
    Inet1.Password = "noneofyourbusiness" 'Password to logon to remote
    Inet1.UserName = "mcrider" 'UserID to logon remote
    Inet1.Execute , "CD incoming" 'Change remote dir to incoming
'WAIT UNTIL WE'RE FINISHED EXECUTING THE CD COMMAND.
        Do
          DoEvents
        Loop Until Not Inet1.StillExecuting
    Inet1.Execute , "SEND c:/autoexec.bat testfile"
'WAIT UNTIL WE'RE FINISHED EXECUTING THE SENDCOMMAND.
        Do
          DoEvents
        Loop Until Not Inet1.StillExecuting Inet1.Execute , "CLOSE"



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

dwalexCommented:
I didn't know anything about FTP when I wanted to enable a VB app as an FTP client. Using the freeware FTP client DLL from France made it very simple. You'll find your answer there.
0
mhjordanCommented:
Try this.  It's a "quick and dirty" way of FTPing.

Sub Main()
Dim strFilename
strFilename = "C:\WINNT\system32\Cmd.exe"

 Shell (strFilename)
 SendKeys "~FTP Servername~", True
 SendKeys "FTP Servername~", True
 SendKeys "username~", True
 SendKeys "password~", True
 SendKeys "put filename~", True
 SendKeys "bye~", True
 SendKeys "exit~", True
End Sub

The tilde (~) signs are necessary.  They indicate a line break.  Don't ask me why, but I have always had to send the FTP statement twice, because the first one invariably ends up getting cut off.

The FTP Servername opens a file transfer protocol connection to your server.  The username and password are self-explanatory.  The "put" statements puts a file onto the server.  "bye" shuts down the FTP connection and "exit" exits the command prompt.  Like I said... it's quick and dirty, but it does the trick most of the time.
0
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.