Hi all ,
Iam looking for a sample code where i can open a ftp connection ,send text file and save it.. can anybody help me with this...
thanks
Printable View
Hi all ,
Iam looking for a sample code where i can open a ftp connection ,send text file and save it.. can anybody help me with this...
thanks
....
You could simply shell out to the FTP.exe program or you can use the FtpPutFile API function.The steps are to call InternetOpen and with the returned handle call the InternetConnect function. The handle returned by that function is in turn used with the FtpPutFile function. When you're done you need to close the two handles using InternetCloseHandle.VB Code:
Private Declare Function InternetOpen Lib "wininet.dll" _ Alias "InternetOpenA" ( _ ByVal sAgent As String, _ ByVal nAccessType As Long, _ ByVal sProxyName As String, _ ByVal sProxyBypass As String, _ ByVal nFlags As Long) As Long Private Declare Function InternetConnect _ Lib "wininet.dll" Alias "InternetConnectA" ( _ ByVal hInternetSession As Long, _ ByVal sServerName As String, _ ByVal nServerPort As Integer, _ ByVal sUserName As String, _ ByVal sPassword As String, _ ByVal nService As Long, _ ByVal dwFlags As Long, _ ByVal dwContext As Long) As Long Private Declare Function InternetCloseHandle _ Lib "wininet.dll" ( _ ByVal hInet As Long) As Integer Private Declare Function FtpPutFile _ Lib "wininet.dll" Alias "FtpPutFileA" ( _ ByVal hFtpSession As Long, _ ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, _ ByVal dwFlags As Long, _ ByVal dwContext As Long) As Boolean
I've attached an article I wrote a few years back that explains these functions in more detail.
Sorry didn't notice that Dave already posted my article :)
:thumb: Very well-written I might add.Quote:
Originally Posted by Joacim Andersson
I wasn't able to find the CFTP Class you made. Where is it, I'd like to use it.Quote:
Originally Posted by Joacim Andersson
Thanks!
Dave
I don't have the origional CFtp class I made for that article anymore, but I have an extended version of it :). But since you asked so nicely or maybe because of the chance to get this post rated :) I've post not only that class but a whole project. This project is my File Courier application that comes with my Source Edit program. File Courier is a complete FTP client. You may not redistibute this code or the whole application but you may use the classes in it in your own application. Just look at the project as an implementation of how to use the different classes.
Cheers,
J
Cross my heart, hope to die, stick a needle in my eye!Quote:
Originally Posted by Joacim Andersson
hehe I am only intertested in your classes... Thanks alot! I may modify the Classes slightly to suit my personal goals. Hope thats OK, I can post any new changes should you be interested in them.
Not to worry, the project cannot be loaded or executed or compiled anyway. It barfs on a few missing DLLs:
Line 21: Class CCRPFolderTV6.FolderTreeview of control ftree was not a loaded control class.
Missing: TimerEx.dll
Oh yeah, sorry about that. The FolderTreeView can be downloaded from http://ccrp.mvps.org and I'll upload the source for the Timer.Quote:
Originally Posted by Dave Sell
Do whatever you want with the classes, you don't have to post the changes if you don't want to.Quote:
Originally Posted by Dave Sell