{"id":27647,"date":"2021-10-13T17:05:49","date_gmt":"2021-10-13T15:05:49","guid":{"rendered":"https:\/\/help.qualiware.it\/qw-help\/?p=27647"},"modified":"2021-10-13T17:13:35","modified_gmt":"2021-10-13T15:13:35","slug":"scaricamento-file-da-sftp","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/scaricamento-file-da-sftp\/","title":{"rendered":"Scaricamento file da SFTP"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente script \u00e8 un esempio di come si possono scaricare i file contenuti in una cartella da un server SFTP. \r\n' Utilizza la libreria SSH.NET, installata con la release 2021.06+4.\r\n' Al seguente link: https:\/\/ourcodeworld.com\/articles\/read\/369\/how-to-access-a-sftp-server-using-ssh-net-sync-and-async-with-c-in-winforms\r\n' \u00e8 possibile trovare altri esempi di utilizzo\r\nDim host As String = \"&lt;host&gt;\" ' es. ftp.qualiware.it\r\nDim username As String = \"&lt;user&gt;\"\r\nDim password As String = \"&lt;password&gt;\"\r\nDim remoteDirectory As String = \"\/&lt;eventuale percorso&gt;\"\r\n\r\ndim sftp As Renci.SshNet.SftpClient = New Renci.SshNet.SftpClient(host, username, password)\r\n\r\nTry\r\n    sftp.Connect()\r\n    Dim files = sftp.ListDirectory(remoteDirectory)\r\n   \r\n    dim file\r\n    For Each file In files \r\n    \t Dim pathRemoteFile As String = remoteDirectory+\"\/\"+file.name\r\n         Dim pathLocalFile As String = Funique(Q95_PATH_TEMP+\"\\TEMP???????\"+system.io.path.getextension(file.name))\r\n\t\t\r\n         Dim fileStream As System.Io.Stream = System.Io.File.OpenWrite(pathLocalFile)\r\n         sftp.DownloadFile(pathRemoteFile, fileStream)\r\n         fileStream.close()\r\n \r\n         form.FileDownload(pathLocalFile,file.name)         \r\n    Next\r\n\r\n    sftp.Disconnect()\r\n\r\nCatch e As Exception\r\n    form.alert(\"Errore SFTP: \" &amp; e.message)\r\nEnd Try\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; Il seguente script \u00e8 un esempio di come si possono scaricare i file contenuti in una cartella da un server SFTP. &#8216; Utilizza la libreria SSH.NET, installata con la release 2021.06+4. &#8216; Al seguente link: https:\/\/ourcodeworld.com\/articles\/read\/369\/how-to-access-a-sftp-server-using-ssh-net-sync-and-async-with-c-in-winforms &#8216; \u00e8 possibile trovare altri esempi di utilizzo Dim host As String = &#8220;&lt;host&gt;&#8221; &#8216; es. ftp.qualiware.it Dim&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71,82],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/27647"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=27647"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/27647\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=27647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=27647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=27647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}