Quick Search for:  in language:    
FTP,Make,simple,Client,allows,read,write,remo
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,290,928. lines
 Jobs: 179. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for Visual Basic.
Check Placement of Form on Screen
By CubeSolver on 11/20


RT Full Duplex
By Brian Black on 11/20


C++ Template Hack
By OpcodeVoid on 11/20


Click here to see a screenshot of this code!DeskTop Generator
By Ziad Said on 11/20

(Screen Shot)

SQLMan
By Darwin H. de Leon on 11/20


Klik! CompareLib...Co mpare and synchronize schema differences in your Access databases...
By Özden Irmak on 11/20


listview000sher if
By Sherif Omran on 11/20


Using ComboBox instead of TextBox
By SMA Soft on 11/20


Click here to see a screenshot of this code!ColorFade
By SMA Soft on 11/19

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Make Your Own FTP Client

Print
Email
 

Submitted on: 4/30/1999
By: Vikramjit Singh  
Level: Not Given
User Rating: By 105 Users
Compatibility:VB 4.0 (32-bit), VB 5.0, VB 6.0

Users have accessed this code 27702 times.
 
 
     Make a simple FTP Client that allows you to read and write to a remote computer
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Make Your Own FTP Client
' Description:Make a simple FTP Client t
'     hat allows you to read and write to a re
'     mote computer
' By: Vikramjit Singh
'
' Inputs:The IP address and local file n
'     ame , path.
'
' Assumes:Set Project Refrences to MSINE
'     T.OCX before you run the code
Or you could Set Project components and check on Microsoft Internet transfer control...then drag the MSINET control onto the form.In that Case comment the line
'Dim Inet1 As New InetCtlsObjects.Inet
'
' Side Effects:'******************NOTE**
'     ************
' This code runs fine on a local intrane
'     t... for ALL versions of VB.
' This code has also been tested by me t
'     o work on the INTERNET for VB5
' (SP3). if you have VB5 PLEASE upgrade 
'     to SP3...to resolve known
' bugs in INET. The code will then run l
'     ike a breeze. VB 5 SP3 is FREE
' at http://www.microsoft.com/msdownload
'     /vstudio/sp97/vb.asp
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=1698&lngWId;=1'for details.'**************************************

' Dim Inet1 As New InetCtlsObjects.Inet
Dim FTPHostname As String
Dim Response As String
Public Sub writefile(pathname As String, filename As String, IPaddress As String)

'note ..your ip addres specified should ' be that of an anonymous FTP Server. 'otherwise use ftp://ftp.microsoft.com k ' ind of syntax FTPLogin FTPHostname = IPaddress Inet1.Execute FTPHostname, "PUT " & pathname & filename & " /" & filename Do While Inet1.StillExecuting DoEvents Loop
Exit Sub End Sub
Public Sub getfile(pathname As String, filename As String, IPaddress As String)
'note ..your ip addres specified should ' be that of an anonymous FTP Server. 'otherwise use ftp://ftp.microsoft.com k ' ind of syntax FTPLogin FTPHostname = IPaddress Inet1.Execute FTPHostname, "GET " & filename & " " & pathname & filename Do While Inet1.StillExecuting DoEvents Loop
Exit Sub End Sub
Private Sub FTPLogin()
With Inet1 .Password = "Pass" .UserName = "Anonymous" End With
End Sub


Other 11 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/1/1999 7:31:00 AM:Ian Ippolito
Input paramaters:
IpAddress=url and 
diretory of 
file
example:ftp.microsoft.com
FileNam
e=name of file to 
download
example:disclaimer.txt
PathNa
me=local path name
example:c:\
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/2/1999 8:52:00 AM:Ben Sullivan
What if I wanted to log on to an ftp 
site that requires a user name and 
password?  Could you update this code 
to support that feature?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/4/1999 6:30:00 PM:Marc
you could try the 
following...
Inet1.URL = 
"FTP://ftp.domain.tld"
Inet1.Password 
= "dummypass"
Inet1.UserName = 
"dummyuser"
Text1.Text = Inet1.OpenURL
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/6/1999 2:13:00 AM:Aamir Nizami
can u demonstrate me how u develop this 
code 
  i mean what is the theme of 
this code
how this code will work 
plz reply me 
 I shall be very 
thankful to u
  u can also e-mail to 
me on
  naamir@mailcity.com
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/7/1999 5:21:00 PM:Jeff
can you please send me a form of the 
whole FTP codes and everything I need a 
example so I can understand how to work 
it please I would appreciate it cause 
the .bas file doesnt help me any. 
Thankyou!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/10/1999 9:56:00 PM:Ian
im trying to make a program that 
downloads a file in the background and 
then displays it in a text box once its 
done, can this be done with this code?? 
if not does anyone know hos i could and 
send me an example, i really need 
it..Email me PLEASE!!!!! THANKS IN 
ADVANCE
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/11/1999 4:38:00 AM:LatexRat
hmm.. seems like people are having 
trouble?!  I would explaine, but i dont 
have the time right now.. If you are 
interested in me making an example 
please email me!  I can whip one up 
real quick.. Also any questions .. 
Email me w/ them also .. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/11/1999 1:03:00 PM:Birk
I am trying to find a way to list 
directories that are located on a web 
server in a treeview.  When a directory 
is choosen the files within that 
directory would be listed in a 
listview.  Sort of like windows 
explorer only for remote directories 
and files in my assigned space on a web 
server.  Any help or samples would be 
appreciated.  email me at birk@home.com 
   thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/11/1999 11:41:00 PM:Thomas Bachleitner
The following piece of program does not 
work. It 
hangs at the Inet1.Execute 
command and does
not return at least 
for 1 minute (the host is
in the 
LAN).
Please help!
thank you in 
advance!
----------------------------
Public Sub getfile()
  Inet1.Protocol 
= icFTP
  FTPHostname = "myhost"
Inet1.URL = "ftp://" + myhost
Inet1.Password = "passw"
Inet1.UserName = "usern"
  Debug.Print 
Inet1.OpenURL
  Inet1.Execute 
FTPHostname, "GET /path/tmp/prn.out 
c:\prn.out"
  Do While 
Inet1.StillExecuting
    DoEvents
Loop
  Exit Sub
End Sub
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/16/1999 9:38:00 PM:SmokeDoGG
can you please send me a form of the 
whole FTP codes and everything I need a 
example so I can understand how to 
work it please I would appreciate it 
cause 
the .bas file doesnt help me 
any. Thank you!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/18/1999 4:00:00 AM:Marcus
The code works ok, but when 
transferring text files from a remote 
computer all the carriage return 
characters are stripped out (vbCrLfs).  
Does anyone else have the same problem, 
or is it a one off case?
Cheers
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/18/1999 12:14:00 PM:LatexRat
I made a simple little example out of 
it... You can get it 
at:
members.xoom.com/808games/ftpsamp.z
ip
Any Questions w/ it just email me :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/19/1999 2:02:00 AM:Arjan Almekinders
instead of Inet1.Execute FTPHostname, 
"PUT " & pathname & filename & "/ " & 
filename
I'd use 
Inet1.Execute 
FTPHostname, "PUT " & Chr(34) & 
pathname & filename & "/" & Chr(34) & " 
" & Chr(34) &filename&Chr(34)
This 
way, it is possible to download files 
with large names containing spaces.
& 
Chr(34) &
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/19/1999 2:12:00 AM:Arjan Almekinders
Another issue coming up here:
How do I 
transfer the files and save them in 
DOS-mode (ie chr(10)+chr(13) instead of 
just chr(10) on the end of each line)?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/19/1999 8:19:00 PM:Vbmaster
Has anyone here worked with the API's 
(no .ocx!) on FTP-transfers, i would 
like to find the information needed to 
get a progressbar working, what is used 
some kind of callback-function? Thnx.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/20/1999 12:18:00 AM:PGPKeys
Hey, great code!. This is one of the 
few VB mailing lists i actually 
subscribe to. I've learned more here 
than from any book. Glad to see otehrs 
like this author sharing the knoeledge 
a bit.
My question kind of applies 
to this. I run both Windows and Linux. 
The problem I have with any FTp 
(including that done withthis code) is 
taht under Windows any text file I get 
comes in with Crl+Lf codes embedded 
(just part of how Windows hadnels EOL 
chars i guess. I need to be able to 
have it download a text file (for like 
perl scripts and such) and have it 
strip out those codes before it saves 
the file locally. Yet I also want the 
option to let the ftp client know if i 
want the Win95/98 format (leaving the 
coes in the text) or if I want to save 
in a format compatable with Linux. (The 
removal of the EOl chars). Any 
ideas?
Thanks in advance.
PGPKeys
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/21/1999 12:58:00 AM:Vikramjit Singh
Please Upgrade your VB 5 to SP3 
(Service Pack 3) at 
http://www.microsoft.com/msdownload/vstu
dio/sp97/vb.asp
This code should 
then work just fine. I have tested it 
on SP3. over the internet.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/22/1999 2:13:00 AM:Liam
Im trying to make a program that can 
upload some text to my website, and 
then another program that retrieves it, 
anyone gt any idea's??
Thanx in advance
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/22/1999 11:47:00 PM:Tim Hall
This is kind of related, i want to be 
able to send binary and ascii 
files
from one client application to 
another alot like the ICQ file 
transmission
(a bit more reliable if 
possible) without having to buy an 
acitve x control
free ones are ok 
though any help would be greatly 
apprieciated please email 
me at 
timhall@tig.com.au or ICQ me on 
26185027.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/24/1999 3:19:00 PM:tyler robbins
i am trying to intergrate this with a 
internet chat program i made, so that 
you can transfer files between users. 
Any ideas of how i could do this? if 
you can email me and ill send you my 
source
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/27/1999 9:03:00 AM:Michael
Hi, the code is very nice, i developed 
very rapid a few days ago a kind of 
same code. What I like to know is, is 
it possible to download automatically 
more than 1 datafile, I tried a lot 
with 1 is no problem but with more than 
1, I think it must be easy, but I don't 
see it. Did anybody have an idea.
you 
can write to my e-mail adress thank you
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/27/1999 11:48:00 AM:Latexrat
Ian,  you cannot do that in Visual 
Basic.
Try assembly.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/1999 1:04:00 AM:Paul
hey!
i am trying to get this code to 
work in 
VB4, and no luck.  i need a 
thing called
msinet.ocx, and the only 
one i've been 
able to download from 
the 'net, is one 
that won't let me 
use it in a development
environment.  
am i missing something 
here??!?  or 
can't i use this code in VB4?
any 
help would be great!
my email is 
pennington.p@hbs.net.au
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/10/1999 5:07:00 AM:Manny Popes
Hi guys,
Just thinking can we make 
this FTP sending and receiving in 
Passive mode?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/22/1999 12:19:00 PM:Bob
can you please send me a form of the 
whole FTP codes and everything I need a 
example so I can understand how to 
work it please I would appreciate it 
cause 
the .bas file doesnt help me 
any. Thankyou!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/12/1999 10:28:00 PM:vbeast
Thanks for the zip file LatexRat.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/19/1999 6:32:00 PM:zu
Can you please send me the whole 
program
'cause i really need it for my 
project.
i'll be grateful then, 
thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/28/1999 11:08:00 AM:Adam
Can someone please help me to 
understand how to make a simple ftp 
program that works perfect, I can't 
find any simple examples anywhere, i'm 
trying to use inet and I don't get it, 
does anyone know of a sample program 
with explicit instruction within the 
code?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/2/1999 4:39:00 AM:Craig
I need to develop a piece of code 
which
will dump and entire directory 
of files
including sub directories 
onto a FTP 
server. The code needs to 
run on its 
own since this will be 
automated. 
Can anyone please help 
??  
Regards
Craig
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/3/1999 9:32:00 AM:Ken
Nice piece of Code. What has to be done 
to get it to work with sFTP. I want to 
automate it to get a daily log file 
that is on a sFTP server?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/5/1999 11:39:00 AM:naveen rao
I was working on the same code and have 
done exactly the same thing. But as 
many of them have commented, I could 
transfer files but only in binary mode. 
My project requirement is that I 
transfer files in text (ASCII) mode. I 
have upgraded to SP3 but still I have 
the same problem. Has anyone solved 
this?? Please revert 
ASAP
Thanks
Navs
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/7/1999 8:20:00 PM:Wyatt
Nice code ... but:
I think I have the 
reverse problem from Navs.
I can open 
a command prompt, ftp to the server, 
and put a binary or text 
file.
However, with Inet it will only 
PUT a text file.  I need to ftp a 
binary.  I'm using VB6...
and very 
desparate.
Thanks,
Wyatt
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/13/1999 8:46:00 PM:Eric
Nice, but does anybody have some ftp 
server source to go with it?  That 
would be helpful. Thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/13/1999 10:40:00 PM:need2know
can you actually get files from other 
peoples computers?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/17/1999 11:15:00 AM:john
it doesn't seem to work, here's what i 
got 
Call 
getfile("C:\windows\desktop\", 
"main.htm", 
"server13.hypermart.net/blike/")
some
one please mail me or help me out, 
thanks
john
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/24/1999 6:28:00 AM:Logan
I am trying to do this, but I need to 
display all the files in the current 
directory on a file list box or however 
they did it in CuteFTP. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/26/1999 5:00:00 PM:DC
How do you code a fix block or variable 
block for uploading to a mainframe 
environment???
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/27/1999 10:08:00 AM:Doug
Does anyone have a solution to the 
problem of missing VbCrLf's when using 
this control to GET a file from a 
remote computer????
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/29/1999 2:36:00 AM:xWz24
can anyone teach me how to continue 
downloads on the internets, like 
GetRight & Go!Zilla??? email me and 
we'll talk
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/11/1999 8:57:00 AM:maoak
Why i can't access intranet 
network?
Error "icConnectFailed 35754 
"Unable to connect to remote host" 
Please send mail to me.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/19/1999 7:59:00 AM:Raider
Hello, I was looking over this code and 
found it to be very useful in 
developing my own FTP Client.
Alot of 
people have listed problems about 
getting it to log onto a remote host 
that is running 
Private Server 
software. To acomplish this you have to 
make your program han a With while 
Executing
and send your Inet1.UserName 
and Inet1.Password and it will work, I 
just tested this theory before
writing 
this Message and it worked just fine.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/7/2000 6:04:37 PM:Zaid
hi there,
does any one know how to 
create a directory on the server 
thorugh vb??? lemme no if u 
do.
---thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/16/2000 2:37:29 PM:rsine
I tried using this code to access an 
ftp server outside my firewall and can 
never make a connection.  I use the 
OpenURL and can get through but really 
need to use Execute for efficiency.  I 
use a Web proxy server (i.e. 
web."myproxysever".com).  Can you offer 
me any advice or point me in the 
direction of someone who can?  I would 
be grateful for the help.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/16/2000 9:50:18 AM:Julie
The Internet Transfer Control is great 
if there are no binary/ASCII issues, 
but it cannot resolve an ASCII 
requirement.  I found a great article 
on EarthWeb by Chris Eastwood called 
"FTP Access through a Class Module for 
VB5/6 WinInet.DLL".  There is an 
attached project that you can download. 
 Also I downloaded a free FTP ActiveX 
Control from DevPower the other day 
which works fairly well, although it 
didn't have the degree of control over 
processing that I wanted.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/2/2000 6:21:06 PM:Brian G.
Winning award for using a 
control???
What is this world comming 
to?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/13/2000 9:31:03 PM:desperate
i find this codes useful but its not 
what i really need...well im a yr2 
student sudent IT at some 
college...currently having my 
attachment...the company had asked me 
to develop a visual basic program...but 
im not sure how to go about it...
HELP 
ME PLS!!!!
CASE SCENARIO: 
The 
Company has an SQL database that is 
being updated many times during the 
day. As a backup, the company has an 
FTP website by which they upload onto 
several times during the day.
THE 
TASK:
To create a VISUAL BASIC v6.0 
program which will run a query every 
hour on the SQL database. If there is a 
change in the database, the program 
will upload the new database containing 
the new information onto the FTP 
website. Should there be a disruption 
on the filr transfer, the program will 
reload the information were the file is 
disrupted. 
(PS> XML preferred)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/8/2001 4:31:01 PM:thatgirl@tsixroads.com
I am using the execute command and I 
need to transfer a file in ASCII mode.  
There has to be a way to do it!!  I 
have a file that has been FTP'd from a 
UNIX machine so when it comes down it's 
messed up.  Does anyone know how to 
specify the transfer mode?  ANY help 
would be appreciated.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/1/2002 8:10:40 AM:maia
Ok.  I'm obviously missing something.  
I do'nt seem to have this msinet.ocx on 
my machine.  There's a Microsoft 
Internet Control but it's a .dll.  
Please point me in the right 
direction.
thanx
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/26/2002 11:35:46 AM:
I am unable to 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/26/2002 11:38:43 AM:
I am unable to "PUT" a file in 
ASCII(text).  It sends it in BINARY.  I 
am referencing the MSINET.OCX in an 
ASP.
Is there a setting or code I need 
to include to send in ASCII?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/23/2003 5:53:45 AM:Drew Tempelmeyer
I am trying to make a P2P program, I 
may use this method
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.