Load picture from FTP to PictureBox with WinSCP .NET assembly

前提是你 提交于 2019-12-10 12:33:33

问题


I am using WinSCP .NET assembly to transfer files by FTP. Couple days ago I developed new module to show pictures in PictureBox control. What I would like to achieve is to list picture's paths inside listbox or whatever else and then when click on this path to be able to open the picture in PictureBox. The point is pictures are on remote location on my FTP and I have no idea is it possible using WinSCP (FTP) to use get their path and then using the paths to show up given picture inside PictureBox. Anyone has idea is it possible or not?


回答1:


You have to download the file to a local temporary file and load the file to the picture box. You cannot load the remote file directly.

' Unique temporary path 
Dim tempPath As String = Path.GetTempFileName()
' Download the image
session.GetFiles(RemotePath.EscapeFileMask(remoteImagePath), tempPath).Check()
' Load tempPath to picture box
<your code here>
' Delete the temporary file
File.Delete(tempPath)

(I do not do VB.NET, so the syntax may not be 100% correct)



来源:https://stackoverflow.com/questions/32945059/load-picture-from-ftp-to-picturebox-with-winscp-net-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!