B4J Question B4j smb

Mirko Melegari

Member
Licensed User
Longtime User
I am using SMB Libraries on B4A and i am able to read a txt file on an external server with the IP external and credentials .
There is the equivalent on B4J ? Somebody has any sample to read directly a txt file on an external server knowing IP,User,password,directory,filetxt

thanks Mirko
 

stevel05

Expert
Licensed User
Longtime User
Have you tried using the same library? The wrapped library is a Java library (not Android specific) and may well just work, although I haven't tried it.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It will be the same as with B4a. I don't know the library so I can't be more specific, but copy the xml and jar files to your B4j addl libraries. If you needed to use the addljar directive, do that the same too.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Just tried it out on my Network Access Disk and it works, you don't need an additionalJar declaration. But you do need to copy the jcifs.jar to your additional libs folder as well.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I just did this, there is no authentication, but it should be exactly the same as with B4a:

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim SMB1 As SMB
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
   
    SMB1.Initialize("SMB1")
    SMB1.ListFiles("smb://NAS/", "")

    Log(SMB1.Version)
   
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub SMB1_ListCompleted(Url As String, Success As Boolean, Entries() As SMBFile)
    Log("ListCompleted")
   
    If Not(Success) Then
        Log("ListFiles failed : " & LastException)
    Else
        For i = 0 To Entries.Length - 1
            Log("*****************")
            Log(Entries(i).Name)
            Log(Entries(i).Directory)
            Log(DateTime.Date(Entries(i).LastModified))
            Log(Entries(i).Parent)
            Log(Entries(i).Size)
        Next
    End If
End Sub
 
Upvote 0

Mirko Melegari

Member
Licensed User
Longtime User
Dear steve
Everything works well in a local network, but i need to use SMB from external IP , probably i have to use
SMB1.Initialize2(...... giving User and Password to reach files in the server. Do you have any code to give parameters in the proper way ?
thanks Mirko
 
Upvote 0
Top