问题
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