joe_pool_is Posted July 5, 2005 Posted July 5, 2005 I'm looking for a way to connect to one of our remote sites via FTP. I've been searching MSDN, but so far I am unable to find a topic detailing how to do this. The closest I found was an article on IIS, which may now encapsulate FTP features. I was not readily able to see how to get my application to do basic FTP commands, however. My application need to connect to ftp into the server and download a small text file after booting up (this text file will function as a security key). Occasionally, as updates come out, this small text file will also notify the program that it needs to download the latest patches. What keywords should I be looking under? I have been using "ftp sdk" and "ftp skd msdn", but these pulled up lists that were not what I wanted. Quote Avoid Sears Home Improvement
a_jam_sandwich Posted July 5, 2005 Posted July 5, 2005 intresting way to update ... I have a ftp control on http://www.planet-source-code.com for ftp'ing FTP Control though you may want to try a system like a HTTP updater see my website for details on that Live updater Regards Andy Quote Code today gone tomorrow!
joe_pool_is Posted July 5, 2005 Author Posted July 5, 2005 Interesting Jam Man. Your "updater" seems to be just what I am looking for using XML. I will look into it. Thanks. Quote Avoid Sears Home Improvement
decrypt Posted July 5, 2005 Posted July 5, 2005 here's an easy way to download files: Option Strict Off Option Explicit On Imports System.Runtime.InteropServices Module FTPDownload Dim frm1 As Form1 Private Declare Function InternetCloseHandle Lib "wininet.dll" _ (ByVal hInternet As IntPtr) As Boolean Private Declare Auto Function InternetOpen Lib "wininet.dll" _ (ByVal lpszAgent As String, _ ByVal lAccessType As Integer, _ ByVal lpszProxyName As String, _ ByVal lpszProxyBypass As String, _ ByVal dwFlags As Integer) As IntPtr Private Declare Auto Function InternetConnect Lib "wininet.dll" _ (ByVal hInternet As IntPtr, _ ByVal lpszServerName As String, _ ByVal nServerPort As Short, _ ByVal lpszUserName As String, _ ByVal lpszPassword As String, _ ByVal dwService As Integer, _ ByVal dwFlags As Integer, _ ByVal dwContext As Integer) As IntPtr Private Declare Auto Function FtpGetFile Lib "wininet.dll" _ (ByVal hConnect As IntPtr, _ ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, _ ByVal fFailIfExists As Boolean, _ ByVal dwFlagsAndAttributes As Integer, _ ByVal dwFlags As Integer, _ ByVal dwConext As Integer) As Boolean Private Declare Auto Function FtpPutFile Lib "wininet.dll" _ (ByVal hConnect As IntPtr, _ ByVal lpszLocalFile As String, _ ByVal lpszNewRemoteFile As String, _ ByVal dwFlags As Integer, _ ByVal dwContext As Integer) As Boolean Dim currentnumber As Integer Sub Main() currentnumber = currentnumber + 1 Dim hInet As IntPtr Dim hConn As IntPtr hInet = InternetOpen("my ftp", 1, vbNullString, vbNullString, 0) Console.WriteLine("hInet = {0}", hInet) hConn = InternetConnect(hInet, "no.prefix.com", 21, "", _ "", 1, 0, 0) Console.WriteLine("hConn = {0}", hConn) Console.WriteLine("FtpGetFile Result = {0}", FtpGetFile(hConn, _ "folder/in/ftp.txt", "locationftp.txt", True, 1, 1, 0)) InternetCloseHandle(hConn) InternetCloseHandle(hInet) End Sub Quote
joe_pool_is Posted July 11, 2005 Author Posted July 11, 2005 I am using MFC and C++ in my ftp program (the targets that run it will not have the .NET framework installed). I followed a nice little example on downloading files via ftp, and it's first line was to include the WinInet.h file:#include <wininet.h>When I try to compile my small program, I get errors that point back to code that is declared in the WinInet.h file. I have started to include other header files that include definitions to things that WinInet.h needs (i.e. DWORD in windef.h), but now I am getting errors in the declarations found in those new files! Does someone know if there is a basic header file that I missed somewhere? (code is in this ftp zip file http://www.xtremedotnettalk.com/attachment.php?attachmentid=&stc=1)FTP.zip Quote Avoid Sears Home Improvement
IngisKahn Posted July 11, 2005 Posted July 11, 2005 /me loves System.Net.FtpWebRequest :) Quote "Who is John Galt?"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.