Italian [B4A] tasferire file da android a pc Tcp/ip

Star-Dust

Expert
Licensed User
purtroppo ho gia visto e rivisto, ma non riesco a venirne a capo.
Io potrò guardare martedì, sto andando in "vacanza" per un giorno :oops:
 

Xfood

Expert
Licensed User
buona vacanza..... tranquillo, grazie
se trovo una soluzione la pubblico qui,
altrimenti vuol dire che non ho trovato la soluzione
 

Star-Dust

Expert
Licensed User
Credo che devi usare copy (e non copy2) per scaricare dal pc ad Android

Copy2 e da Android a Pc
 
Last edited:

Xfood

Expert
Licensed User
non me lo compila neanche

1635702202284.png



allego tutto il codice

grazie per tutto
B4X:
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
 

LucaMs

Expert
Licensed User
Longtime User
non me lo compila neanche
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").

P.S.: il compilatore ti segnala che hai scritto troppi parametri per il metodo Copy.
 

Xfood

Expert
Licensed User
Risolto....
Grazieeeee



ecco il codice corretto
B4X:
 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

in pratica il file che si trova sul pc deve essere inserito nelle credenziali
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB") & cFileTrasf

tradotto e' cosi:
credentials.Share = "smb://192.168.1.100/c-drive/preleva/setup.ini"
e poi il copy in questo modo....
smbClient.copy(smbResource,cPathFileOut, cFileTrasf)
 
Top