{"id":3191,"date":"2012-06-26T12:07:08","date_gmt":"2012-06-26T10:07:08","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=3191"},"modified":"2014-03-12T19:18:56","modified_gmt":"2014-03-12T17:18:56","slug":"ftp-downloading-files-using-patterns","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/ftp-downloading-files-using-patterns","title":{"rendered":"FTP downloading files using patterns"},"content":{"rendered":"<p>Downloading files using patters is a unique feature of our <a href=\"\/ftp\">FTP .NET component<\/a>. It allows you fast download of files of certain types.<\/p>\n<p>Here&#8217;s the sample that download all text files (*.txt) files from remote Uploads folder to Downloads folder located on C drive. Remote search includes <strong>all child folders recursively<\/strong> &#8211; note the <em>true<\/em> parameter in <em>RemoteSearchOptions<\/em> constructor. Ftp component is going to<strong> create all necessary folders<\/strong> on the local computer.<\/p>\n<h2>Download using wildcard pattern<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (Ftp ftp = new Ftp())\r\n{\r\n    ftp.Connect(&quot;ftp.example.com&quot;);    \/\/ or ConnectSSL\r\n    \r\n    Directory.CreateDirectory(@&quot;c:\\Downloads&quot;);\r\n\r\n    RemoteSearchOptions options = new RemoteSearchOptions(&quot;*.txt&quot;, true);\r\n    ftp.DownloadFiles(&quot;Uploads&quot;, @&quot;c:\\Downloads&quot;, options);\r\n\r\n    ftp.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing ftp As New Ftp()\r\n    ftp.Connect(&quot;ftp.example.com&quot;)    ' or ConnectSSL\r\n\r\n    Directory.CreateDirectory(&quot;c:\\Downloads&quot;)\r\n    \r\n    Dim options As RemoteSearchOptions = _\r\n        New RemoteSearchOptions(&quot;*.txt&quot;, True)\r\n    ftp.DownloadFiles(&quot;Uploads&quot;, &quot;c:\\Downloads&quot;, options)\r\n\r\n    ftp.Close()\r\nEnd Using\r\n<\/pre>\n<h2>Download using regex pattern<\/h2>\n<p>You can also use <em>RemoteSearchOptions.UseRegexMatch<\/em> method, if you want to use <strong>regex patterns<\/strong> on remote names:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (Ftp ftp = new Ftp())\r\n{\r\n    ftp.Connect(&quot;ftp.example.com&quot;);    \/\/ or ConnectSSL\r\n    \r\n    Directory.CreateDirectory(@&quot;c:\\Downloads&quot;);\r\n\r\n    RemoteSearchOptions options = new RemoteSearchOptions();\r\n    options.UseRegexMatch(@&quot;^.*$&quot;, @&quot;^.*\\.txt$&quot;, true);\r\n    ftp.DownloadFiles(&quot;Uploads&quot;, @&quot;c:\\Downloads&quot;, options);\r\n\r\n    ftp.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing ftp As New Ftp()\r\n    ftp.Connect(&quot;ftp.example.com&quot;)\t' or ConnectSSL\r\n\r\n    Directory.CreateDirectory(&quot;c:\\Downloads&quot;)\r\n\r\n    Dim options As RemoteSearchOptions = _\r\n        New RemoteSearchOptions()\r\n    options.UseRegexMatch(&quot;^.*$&quot;, &quot;^.*\\.txt$&quot;, True)\r\n    ftp.DownloadFiles(&quot;Uploads&quot;, &quot;c:\\Downloads&quot;, options)\r\n\r\n    ftp.Close()\r\nEnd Using\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Downloading files using patters is a unique feature of our FTP .NET component. It allows you fast download of files of certain types. Here&#8217;s the sample that download all text files (*.txt) files from remote Uploads folder to Downloads folder located on C drive. Remote search includes all child folders recursively &#8211; note the true [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[22,80],"class_list":["post-3191","post","type-post","status-publish","format-standard","hentry","category-ftp-dll","tag-ftp","tag-ftp-component"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3191"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=3191"}],"version-history":[{"count":9,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions"}],"predecessor-version":[{"id":4456,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3191\/revisions\/4456"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=3191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=3191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=3191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}