473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Does anyone know how to ftp file from with in a VB App

Hi all
I am writing an App at the moment and I need to be able to download & Upload
xml files from an ftp server. Does anyone know how this can be done without
using a third party component.

Regards

Neil

Nov 20 '05 #1
8 2271
> I am writing an App at the moment and I need to be able to download &
Upload
xml files from an ftp server. Does anyone know how this can be done without using a third party component.


Try this (may have bugs that need to be worked out which I have not had time
to do)

you can be my guinea pig :)

Dont forget to change the paths to what you need them to be.

PLEASE let me know the problems you encounter. It will be a big help.

Answers like this can be found with the VB.NET/ADO.NET newsgroup search tool
at http://www.kjmsolutions.com/newsgrouptool.htm

Module Module1

' Declare the API functions
' The three that you will use are FtpGetFile (for downloading), FtpPutFile
(for uploading), and InternetConnect (to specify the server and login
credentials)
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal
HINet As Integer) As Integer
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal
sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer)
As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As
String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal
sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer,
ByVal lContext As Integer) As Integer
Private Declare Function FtpGetFile Lib "wininet.dll" Alias
"FtpGetFileA" (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String,
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal
dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext
As Integer) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias
"FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String,
ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean
' example of how to use the FtpGetFile Function

Sub Download()

Dim INet, INetConn As Integer
Dim RC As Boolean

INet = InternetOpen("FTP Connection", 1, vbNullString, vbNullString,
0)
INetConn = InternetConnect(INet, "www.myftpserver.com", 21,
"myuser", "mypassword", 1, 0, 0)
RC = FtpPutFile(INetConn, "FTPFolder/MyFiles/MyFile.txt",
"C:\Temp\MyFile.txt", False, 1, 0, 0)
If RC Then MsgBox("Transfer succesfull!")
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)

End Sub

' example of how to use the FtpPutFile Function

Sub Upload()

Dim INet, INetConn As Integer
Dim RC As Boolean

INet = InternetOpen("FTP Connection", 1, vbNullString, vbNullString,
0)
INetConn = InternetConnect(INet, "www.watyf.com", 21, "myuser",
"mypassword", 1, 0, 0)
RC = FtpPutFile(INetConn, "C:\Temp\MyFile.txt",
"FTPFolder/MyFiles/MyFile.txt", 0, 0)
If RC Then MsgBox("Transfer succesfull!")
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)

End Sub

End Module
Nov 20 '05 #2
* "Neil Rowe" <ne*******@blueyonder.co.uk> scripsit:
I am writing an App at the moment and I need to be able to download & Upload
xml files from an ftp server. Does anyone know how this can be done without
using a third party component.


It's not supported by the framework.

<http://www.freevbcode.com/ShowCode.Asp?ID=4655>
<http://www.allapi.net/downloads/NetFTP.zip>
<http://www.visualbuilder.com/article/viewarticle.asp?id=1234>
<http://www.abderaware.com/> (FTP component)
<http://www.csharphelp.com/archives/archive9.html>
<http://www.codeproject.com/csharp/FTPDriver1.asp>
....

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Thanks for that scorpion53061 I will try it out and let you know the
results. Can you module be amended to allow the deletion of the files
locally and on the ftp server.

Regards

Neil
Nov 20 '05 #4
Can you module be amended to allow the deletion of the files
locally and on the ftp server.


I would imagine so.

Try to stick with what is there at least initally if you wouln't mind :)
Nov 20 '05 #5
Hello Niel

You can do FTP directly through VB.Net. It is a little work, but once done
works nicely.

checkout this link

http://support.microsoft.com/default...en-us%3B812404

--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================
Pocket PC Return On Investment Calculator
Free Download http://64.78.34.175/mcsnet/kwickKalk1.aspx

"Neil Rowe" <ne*******@blueyonder.co.uk> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hi all
I am writing an App at the moment and I need to be able to download & Upload xml files from an ftp server. Does anyone know how this can be done without using a third party component.

Regards

Neil

Nov 20 '05 #6
> >
I am writing an App at the moment and I need to be able to download &

Upload
xml files from an ftp server. Does anyone know how this can be done

without
using a third party component.


Also Neil:

I am working up another class if that fails and this one includes delete,
rename, create directory, delete directory but you will have to email me off
list if you wish to discuss it.

kj*@nospamherecharter.net

remove no spam here.
Nov 20 '05 #7
Yes I would like to discuss your new class. But you email address does not
work.

Regards

Neil

"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...

I am writing an App at the moment and I need to be able to download & Upload
xml files from an ftp server. Does anyone know how this can be done

without
using a third party component.


Also Neil:

I am working up another class if that fails and this one includes delete,
rename, create directory, delete directory but you will have to email me

off list if you wish to discuss it.

kj*@nospamherecharter.net

remove no spam here.

Nov 20 '05 #8
How did the one I sent you work?

My email is kj*@nospamherecharter.net

remove nospamhere

"Neil Rowe" <ne*******@blueyonder.co.uk> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Yes I would like to discuss your new class. But you email address does not
work.

Regards

Neil

"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
>
> I am writing an App at the moment and I need to be able to download & Upload
> xml files from an ftp server. Does anyone know how this can be done
without
> using a third party component.


Also Neil:

I am working up another class if that fails and this one includes delete, rename, create directory, delete directory but you will have to email me

off
list if you wish to discuss it.

kj*@nospamherecharter.net

remove no spam here.


Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
2
by: steve deno | last post by:
In 6i, if there was an LOV on an item and the user entered the field, a box with 3 dots popped up. It seems this does not happen in 9i. Does anyone know why? And how to make that happen? ...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
7
by: Kilian A. Foth | last post by:
I just found this amazing video puzzle game written with the pygame library, which promises to be infinite fun - but I can't get it to decode any video file I own, except the game's own example...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
5
by: spookyu | last post by:
Alright, I'm sure your tired to hearing this but...does anyone know of any GOOD tutorial's for learning c#. The more basic the better, I have NO experience with programing before this other than...
11
by: cj | last post by:
Public Class MyStringLogger Private Shared m_loglock As New Object Public Shared Sub Write(ByVal str As String) SyncLock (m_loglock) Dim sw As New System.io.StreamWriter("c:\validate.log",...
14
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src=""...
4
by: johnguilbert | last post by:
Hi, I have developed an application that I want to make an Evaluation Copy for 1 week. In the past I have used one of the following techniques with each having a drawback: 1. Write to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.