ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Retrieve and display Image from FTP folder using C# and VB.Net in ASP.Net<p>Refer below article.</p> <h1 class="header"><a title="Display List of files from FTP folder with Download option in ASP.Net using C# and VB.Net'a" href="https://www.aspsnippets.com/Articles/Display-List-of-files-from-FTP-folder-with-Download-option-in-ASPNet-using-C-and-VBNet.aspx">Display List of files from FTP folder with Download option in ASP.Net using C# and VB.Net</a></h1> <p>Once you get the list use below article to display the binary image in image control.</p> <h1 class="header"><a title="Display image in Image control based on DropDownList selection in ASP.Net'a" href="https://www.aspsnippets.com/Articles/Display-image-in-Image-control-based-on-DropDownList-selection-in-ASPNet.aspx">Display image in Image control based on DropDownList selection in ASP.Net</a></h1>https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/Mon, 22 Jul 2019 00:26:37 GMTRetrieve and display Image from FTP folder using C# and VB.Net in ASP.Net<p>Hi Sir,</p> <p>i want to get image from my FTP folder and want to display in my browser page</p>https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/Mon, 22 Jul 2019 00:44:43 GMTRetrieve and display Image from FTP folder using C# and VB.Net in ASP.Net<p>Hi&nbsp;Dev@KKM,</p> <p>Check with the below code.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { //FTP Server URL. string ftp = &#34;ftp://yourserver.com/&#34;; //FTP Folder name. Leave blank if you want to list files from root folder. string ftpFolder = &#34;Uploads/&#34;; try { string fileName = &#34;Desert.jpg&#34;; //Create FTP Request. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftp + ftpFolder + fileName); request.Method = WebRequestMethods.Ftp.DownloadFile; //Enter FTP Server credentials. request.Credentials = new NetworkCredential(&#34;Username&#34;, &#34;Password&#34;); request.UsePassive = true; request.UseBinary = true; request.EnableSsl = false; //Fetch the Response and read it into a MemoryStream object. FtpWebResponse response = (FtpWebResponse)request.GetResponse(); using (MemoryStream stream = new MemoryStream()) { response.GetResponseStream().CopyTo(stream); string base64String = Convert.ToBase64String(stream.ToArray(), 0, stream.ToArray().Length); Image1.ImageUrl = &#34;data:image/png;base64,&#34; + base64String; } } catch (WebException ex) { throw new Exception((ex.Response as FtpWebResponse).StatusDescription); } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) &#39;FTP Server URL. Dim ftp As String = &#34;ftp://yourserver.com/&#34; &#39;FTP Folder name. Leave blank if you want to list files from root folder. Dim ftpFolder As String = &#34;Uploads/&#34; Try Dim fileName As String = &#34;Desert.jpg&#34; &#39;Create FTP Request. Dim request As FtpWebRequest = CType(WebRequest.Create(ftp &amp; ftpFolder &amp; fileName), FtpWebRequest) request.Method = WebRequestMethods.Ftp.DownloadFile &#39;Enter FTP Server credentials. request.Credentials = New NetworkCredential(&#34;Username&#34;, &#34;Password&#34;) request.UsePassive = True request.UseBinary = True request.EnableSsl = False &#39;Fetch the Response and read it into a MemoryStream object. Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse) Using stream As MemoryStream = New MemoryStream() response.GetResponseStream().CopyTo(stream) Dim base64String As String = Convert.ToBase64String(stream.ToArray(), 0, stream.ToArray().Length) Image1.ImageUrl = &#34;data:image/png;base64,&#34; &amp; base64String End Using Catch ex As WebException Throw New Exception((TryCast(ex.Response, FtpWebResponse)).StatusDescription) End Try End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/764324/Retrieve-and-display-Image-from-FTP-folder-using-C-and-VBNet-in-ASPNet/Mon, 22 Jul 2019 07:04:13 GMT