

to download the contents of that sub-directory from and then recursively call theis function create that directory on local computer in case we encounter a directory, first we will String ^strFileListData = reader- >ReadToEnd() StreamReader ^reader = gcnew StreamReader(objResponseStream)

Stream ^objResponseStream = objResponse- >GetResponseStream() WebRequestMethods::Ftp::ListDirectoryDetails Gcnew NetworkCredential(pszUserName, pszPassword) set request creddentials (username & password) (FtpWebRequest^)WebRequest::Create(pszRequestURL) String::Concat(pszServerAddress, pszSourcePath) PszServerIP, " :", Convert::ToString(iPortNumber)) String ^pszServerAddress = String::Concat( " ftp://", first we will create the URL to download the file String ^pszSourcePath, String ^pszDestinationPath) Int iPortNumber, String ^pszUserName, String ^pszPassword, Now, we provide the body for these function in a CPP file:Ĭopy Code bool FTPClient::DownloadDirector圜ontents( String ^pszServerIP, this function downloads contents of directory recursivelyīool DownloadDirector圜ontents( String ^pszServerIP, int iPortNumber, String ^pszFileName, String ^pszSourcePath, String ^pszUserName, String ^pszPassword, pszDestinationPath - Path on local computer where the fileīool DownloadFile( String ^pszServerIP, int PortNumber, pszSourcePath - Path where file resides on FTP server. this function downloads a file from a FTP server file and directory information is stored as this structure.īool IsDirectory //if the item is directoryĪrray ^ GetListFromStringData( String ^strFileListData) The Directory detailed list recieved as ftp response is parsed and Make a new project in Visual Studio 2005, Managed C++. Let's make things clear by using the code: Recursion will definitely help us ) Using the code

(That listing contains all the files and sub-directories contained in the directory.) NET provides is that we can fetch the detailed listing of a directory residing on an FTP server. What if we need to download multiple files or if we need to download the entire directory structure (files and sub-directories etc.) from an FTP server. Until now, what we have learned is that we could only download one file at a time. This concept is explained in detail below. This stream is then read to get the file requested from the server. This response is a raw byte stream consisting of the file that was requested from the server. (FtpWebResponse^) objRequest- >GetResponse()
