Io potrò guardare martedì, sto andando in "vacanza" per un giornopurtroppo ho gia visto e rivisto, ma non riesco a venirne a capo.
Io potrò guardare martedì, sto andando in "vacanza" per un giornopurtroppo ho gia visto e rivisto, ma non riesco a venirne a capo.
Public Sub SMB_TRASMETTI As ResumableSub
Dim cFileTrasf As String
Dim cPathFileOut As String
Dim credentials As SMBCred
credentials.Initialize
credentials.Domain = ""
credentials.Username =B4XPages.MainPage.MappaParametri.Get("USERSMB")
credentials.Password =B4XPages.MainPage.MappaParametri.Get("PSWSMB")
cFileTrasf=Nomefile
cPathFileOut=File.DirDefaultExternal
' cPathFileOut=File.DirDefaultExternal ' & "/download/"
' cPathOut= "ORDINE.OUT"
AttesaShow("Trasferimento ... ",$"Attendere ${CRLF}${Modo} ${Nomefile} ${CRLF} SMB://${B4XPages.MainPage.MappaParametri.Get("SERVERSMB")}"$)
Try
If Modo.ToUpperCase="INVIA" Then ' questo e' ok
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB") ' & "/" & "c-drive/FTP/"
smbClient.Initialize("smbClient_Copy", credentials.Domain, credentials.Username,credentials.Password, credentials.Share)
Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String)
If success = False Then
AttesaHide
Return False
End If
If smbobjres <> Null And smbobj <> Null And info = "OK" Then
Dim smbResource As SMBResource = smbobjres
smbClient.Copy2(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
'Wait For smbclient_copy_copyresult(success As Boolean, path As String, filename As String)
Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String)
If success = False Then
'bB = False
Log("ERRORE COPIA")
Else
Log("copia ok")
End If
Sleep(0)
End If
Else 'RICEVI non va
' PTHDATIINSMB
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB")
smbClient.Initialize("smbClient_Copy", credentials.Domain, credentials.Username,credentials.Password, credentials.Share)
Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String)
If smbobjres <> Null And smbobj <> Null And info = "OK" Then
Dim smbResource As SMBResource = smbobjres
' smbClient.Copy2(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
'provato anche cosi
'smbClient.copy(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
' e cosi
smbClient.copy(cFileTrasf,smbResource,cPathFileOut, cFileTrasf)
Wait For smbClient_Copy_CopyResult(success As Boolean, path As String, filename As String)
'Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String)
If success = False Then
'bB = False
Log("ERRORE COPIA")
Else
Log("copia ok")
End If
Sleep(0)
End If
End If
Catch
AttesaHide
Return False
End Try
AttesaHide
Return success
Ma te lo segnala anche l'editor; parametri sbagliati, controlla (io non l'ho mai usata, ergo non ce l'ho, ergo non posso vedere i parametri, che tu puoi vedere, al solito, dopo il "punto").non me lo compila neanche
Else 'RICEVI
' PTHDATIINSMB
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB") & cFileTrasf
smbClient.Initialize("smbClient_Copy", credentials.Domain, credentials.Username,credentials.Password, credentials.Share)
Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String)
If smbobjres <> Null And smbobj <> Null And info = "OK" Then
Dim smbResource As SMBResource = smbobjres
'smbClient.Copy2(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
'provato anche cosi
smbClient.copy(smbResource,cPathFileOut, cFileTrasf)
' e cosi
'smbClient.copy(cFileTrasf,smbResource,cPathFileOut, cFileTrasf)
Wait For smbClient_Copy_CopyResult(success As Boolean, path As String, filename As String)
'Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String)
If success = False Then
'bB = False
Log("ERRORE COPIA")
Else
Log("copia ok")
End If
Sleep(0)
End If
OK Xfood ho provato il tuo "trasmetti_click" e funziona alla grande.provato con SMB2 e tutto funziona abbastanza facilmente
piccolo riassunto per quello che ho fatto
magari puo servire a qualcuno
la libreia l'ho presa da qui
jcifs-ng SMB-Client (SMB2)
Foreword: I do have nearly zero knowledge about SMB-Protocol. I know Windowsshares and how to access them. But my knowledge about the Different Protocolversions is really low. About two weeks ago someone contacted me and asked me to write a wrapper for a SMB Library because the available SMB...www.b4x.com
B4X:#AdditionalJar: slf4j-api-1.7.25.jar #AdditionalJar: bctls-jdk15on-1.58.0.0.jar #AdditionalJar: bcprov-jdk15on-1.59.jar Sub Class_Globals Public smbClient As SMBClient Public glRes, github As SMBResource End Sub Private Sub BtnTrasmetti_Click Dim cPathFileOut as string Dim cPathOut as string cPathFileOut=File.DirDefaultExternal cPathOut= "ORDINE.OUT" ' dominio,Utente,Password,RisorsaPc_Condivisa smbClient.Initialize("smbClient_Copy", "", "Utente","Password", "smb://192.168.1.17/c-drive/FTP/") Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String) If smbobjres <> Null And smbobj <> Null And info = "OK" Then Dim smbResource As SMBResource = smbobjres smbClient.Copy2(cPathFileOut,cPathOut,smbResource, cPathOut) Wait For smbclient_copy_copyresult(success As Boolean, path As String, filename As String) 'Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String) If success = False Then 'bB = False Log("ERRORE COPIA") Else Log("copia ok") End If Sleep(0) End If End Sub Sub smbclient_copy_copyprogress(totalBytes As Long, path As String, filename As String) Log($"SMBClient_CopyProgress(${totalBytes} : ${path}:${filename})"$) End Sub Sub SMBClient_CopyResult(success As Boolean, path As String, filename As String) Log($"SMBClient_CopyResult(${success})"$) Return success End Sub
molto strano, a me copia molto veloce, avvolte ho la sensazione che non ha copiato di quando e veloce,OK Xfood ho provato il tuo "trasmetti_click" e funziona alla grande.
Solo una cosa volevo chiederti
Per trasferire 30kb ci mette circa 30 secondi
Ma è normale questo?
Grazie!!!
Certo, altrimenti non avrebbe funzionato.molto strano, a me copia molto veloce, avvolte ho la sensazione che non ha copiato di quando e veloce,
su windows hai attivato il protocollo smb?
Supporto per condivisione SMB 1.0/CIFS è impostato ma èvolevo dire questo protocollo
View attachment 149912