{"id":1502,"date":"2010-11-06T17:53:36","date_gmt":"2010-11-06T15:53:36","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1502"},"modified":"2013-06-26T10:38:28","modified_gmt":"2013-06-26T08:38:28","slug":"download-file-using-ftp","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/download-file-using-ftp","title":{"rendered":"Download file using FTP"},"content":{"rendered":"<p>First you need to add reference to Ftp.dll <a href=\"\/ftp\">.NET FTP library<\/a>, and import appropriate namespaces:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version\r\n\r\nusing Limilabs.FTP.Client;\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version\r\n\r\nImports Limilabs.FTP.Client\r\n<\/pre>\n<p>The following code downloads the file from <em>reports <\/em>folder on the server, using FTP protocol, and saves it to disk:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version\r\n\r\nusing (Ftp client = new Ftp())\r\n{\r\n    client.Connect(&quot;ftp.example.com&quot;);    \/\/ or ConnectSSL for SSL\r\n    client.Login(&quot;user&quot;, &quot;password&quot;);\r\n\r\n    client.Download(@&quot;reports\\report.txt&quot;, @&quot;c:\\report.txt&quot;);\r\n\r\n    client.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version\r\n\r\nUsing client As New Ftp()\r\n\tclient.Connect(&quot;ftp.example.com&quot;)    ' or ConnectSSL for SSL\r\n\tclient.Login(&quot;user&quot;, &quot;password&quot;)\r\n\r\n\tclient.Download(&quot;reports\\report.txt&quot;, &quot;c:\\report.txt&quot;)\r\n\r\n\tclient.Close()\r\nEnd Using\r\n<\/pre>\n<p>You can also download the file to memory and process it immediately:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version\r\n\r\nusing (Ftp client = new Ftp())\r\n{\r\n    client.Connect(&quot;ftp.example.com&quot;);     \/\/ or ConnectSSL for SSL\r\n    client.Login(&quot;user&quot;, &quot;password&quot;);\r\n\r\n    byte&#x5B;] bytes = client.Download(@&quot;reports\/report.txt&quot;);\r\n    string report = Encoding.Default.GetString(bytes);\r\n\r\n    Console.Write(report);\r\n\r\n    client.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version\r\n\r\nUsing client As New Ftp()\r\n\tclient.Connect(&quot;ftp.example.com&quot;)    ' or ConnectSSL for SSL\r\n\tclient.Login(&quot;user&quot;, &quot;password&quot;)\r\n\r\n\tDim bytes As Byte() = client.Download(&quot;reports\/report.txt&quot;)\r\n\tDim report As String = Encoding.&#x5B;Default].GetString(bytes)\r\n\r\n\tConsole.Write(report)\r\n\r\n\tclient.Close()\r\nEnd Using\r\n<\/pre>\n<p>Finally you can also use the overload that uses any <em>Stream<\/em> as the destination.<\/p>\n<p>You can <a href=\"\/ftp\">download Ftp.dll FTP\/FTPS client for .NET here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First you need to add reference to Ftp.dll .NET FTP library, and import appropriate namespaces: \/\/ C# version using Limilabs.FTP.Client; &#8216; VB.NET version Imports Limilabs.FTP.Client The following code downloads the file from reports folder on the server, using FTP protocol, and saves it to disk: \/\/ C# version using (Ftp client = new Ftp()) { [&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":[15,22,80,57],"class_list":["post-1502","post","type-post","status-publish","format-standard","hentry","category-ftp-dll","tag-c","tag-ftp","tag-ftp-component","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1502"}],"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=1502"}],"version-history":[{"count":6,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1502\/revisions"}],"predecessor-version":[{"id":4137,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1502\/revisions\/4137"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}