B4A Library SMB library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Apr 23, 2012.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Last edited: Dec 31, 2013
    hibrid0 likes this.
  2. monki

    monki Active Member Licensed User

    Thank you so much Erel,
    for your commitment

    monki:sign0060:
     
  3. kaplanerkan

    kaplanerkan Member Licensed User

    Hallo Erel,

    how can i define a "DownloadCompleted" Event with this Library?

    I have tried following code (with and without comments),

    Code:
    Sub SMB1_DownloadCompleted '(ServerPath As String, Success As Boolean)
    '   If Success = True Then
          ToastMessageShow"  ist fertig"False)
    '   End If
       
    End Sub
    but always i get following error;

    "an error has occurred in sub: java.lang.Exception: Sub smb1_downloadcompleted signature does not match expected signature"

    thanks
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should let the IDE define the event for you.
    Write Sub and press on Tab. Choose SMB and let it build the Sub for you.
     
    AirLink likes this.
  5. kaplanerkan

    kaplanerkan Member Licensed User

    Upps..:)
    Thanks Erel.

    here is the correct code of DownloadCompleted:

    Code:
    Sub SMB1_DownloadCompleted (Url As String, RemoteFile As String, Success As Boolean)
       
    If Success = True Then
          
    ToastMessageShow( RemoteFile & "  ist fertig"False)
       
    End If
    End Sub
     
  6. dmtulsa

    dmtulsa Member Licensed User

    Thank you. I've needed this for awhile I also want to thank Roeschti for his help with with hisJCIFS lib. May there the same, I don't know.

    Doug
     
  7. hennemarc

    hennemarc Member Licensed User

    Hello all,

    does the SMB library work with B4A v.1.9 only or with previous versions as well? I am asking this because I want to connect to a shared windows folder on

    \\192.168.0.100\C\ with the credentials

    User = "user"
    PW = "password"

    I want to use the source code from Erel's tutorial, but it does not work:

    Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    SMB1.SetCredentials("user","password","")
    SMB1.Initialize("SMB1")
    End If
    SMB1.ListFiles("smb://192.168.0.100/C/","")
    End Sub

    Does anybody has a good idea?

    p.s.: by using the program (app) "AndSMB" I can see the shared folder content.


    Regards,

    hennemarc
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    It should work with v1.8 as well.
    Which error do you get?
     
  9. hennemarc

    hennemarc Member Licensed User

    The mobile tells me nothing, I just see a black screen!
    Is there a way to see a debug?

    Maybe I do not display the result correctly.
    Can you tell me how I display this in a list on a mobile? Until know, I use this here:

    Sub SMB1_ListCompleted(Url As String, Success As Boolean, Entries() As SMBFile)
    If Not(Success) Then
    Log(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
     
    Last edited: May 8, 2012
  10. Erel

    Erel Administrator Staff Member Licensed User

    You should check the logs (right pane).
     
  11. hennemarc

    hennemarc Member Licensed User

    Yes, got it. I see it works. Sorry for my ignorance.
    Is there a quick and easy way to have that list what I see n the log shown n the mobile as list?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    There are many ways to show data in a list. You can just add it to a ListView instead of logging it.
     
  13. stefanobusetto

    stefanobusetto Active Member Licensed User

    I've written a grid that you can use
     
  14. kaplanerkan

    kaplanerkan Member Licensed User

    Hello,

    i create a txt file with following code:

    Code:
    'Dosyayi kaydet 
                Dim InternBestellungen As String   : InternBestellungen = File.DirRootExternal & "/Kasse/Bestellungen"
                
    Dim tw As TextWriter
                 tw.Initialize(
    File.OpenOutput(InternBestellungen, DosyaKayitIsmi, False))      
    '      
                   Dim Anzahl As Int : Anzahl = BestellungIndex -1 
                
                   tw.WriteLine(
    "[BON]")
                   tw.WriteLine (
    "Kellner=" & Main.ArbeitendeKellner )
                   tw.WriteLine (
    "Cheff=1")
                   tw.WriteLine (
    "Tisch=" & Main.ArbeitendeTischNummer)
                   tw.WriteLine (
    "Anzahl=" & Anzahl )
                   
    For i=0 To Anzahl
                      tw.WriteLine (
    "Bestell_" & i & "=" & dosyakayitBestellungen(i) & "<>" & "0" )
                   
    Next    
                   tw.Close
                   
                   
    Try
                      
    If File.Exists(InternBestellungen,DosyaKayitIsmi) = True Then
                      
                      Main.SMB1.UploadFile(InternBestellungen,DosyaKayitIsmi, 
    "smb://Server/Bestellungen/", DosyaKayitIsmi)
                      
                      
    Log("datei ist gesendet...")
                      
    End If
                      
                   
    Catch
                      
    Log("Datei konnte nicht gesendet werden")
                      
                   
    End Try

    If i edit this txt.file on my Samsung Tablet or Android Handy, its looks like so:

    Code:
    [BON]
    Kellner=
    1
    Tisch=
    6
    Anzahl=
    2
    Bestell_0=
    1*1<>
    Bestell_1=
    1*4<>
    Bestell_2=
    1*5<>

    if i edit this txt.file on Windows XP sp3, its looks like so:
    Code:
    [BON]Kellner=1Tisch=6Anzahl=2Bestell_0=1*1<>Bestell_1=1*4<>Bestell_2=1*5<>
    also, only one line.....


    Although both is the same file, they look different ...



    I try change to my code

    Code:
    tw.WriteLine("[BON]")
                   tw.WriteLine (
    "Kellner=" & Main.ArbeitendeKellner  & CRLF)
                   tw.WriteLine (
    "Cheff=1"   & CRLF)
                   tw.WriteLine (
    "Tisch=" & Main.ArbeitendeTischNummer   & CRLF)
                   tw.WriteLine (
    "Anzahl=" & Anzahl   & CRLF)
                   
    For i=0 To Anzahl
                      tw.WriteLine (
    "Bestell_" & i & "=" & dosyakayitBestellungen(i) & "<>" & "0"   & CRLF )
                   
    Next
    but always the same result; only one line on WindowsXP...


    My Question is, which may be due? Maybe SMB-Protokol?

    thanks
    erkaN
     
  15. manios

    manios Active Member Licensed User

    CRLF erzeugt nur ein LF in Android.
    Ich denke wenn du statt der CRLF Constante die Zeichenkette " & CHR(13) & CHR(10)" verwendest sollte es korrekt sein.
     
  16. kaplanerkan

    kaplanerkan Member Licensed User

    Hallo, manios,

    hast du recht, mit chr(13) chr(10) funktioniert wunderbar.

    Danke für ganz schnelle Antwort.

    gruss
    erkaN
     
  17. HotShoe

    HotShoe Well-Known Member Licensed User

    Missing methods

    Erel,

    Could you please add mkDirs(), renameTo(), canRead(), canWrite(), and getFreeMemory()? I really need these since my attempt at doing this lib reports jcifs doesn't exist in b4a.

    Thanks,

    --- Jem
     
  18. Mahares

    Mahares Well Known Member Licensed User

    I can do this:
    Code:
    SMB1.ListFiles(MyServer, "*.*")  'To get all files in server
    But not this:
    Code:
    SMB1.ListFiles(MyServer, "*.txt, *.tab")
    Is there a way to list files for more than one extension, but not all?
    Thank you
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible. However you can call ListFiles twice. As this is an asynchronous call it should be quick.
     
  20. agraham

    agraham Expert Licensed User

    Version 1.1 of the SMB library, posted here, provides more complete control of the remote file system.

    The additional methods in the SMB object are DiskFreeSpace, MakeDirs, CopyFile and RenameFile together with the additional properties CanRead, CanWrite and IsHidden in the SmbFile object.

    As with the original SMB library the jcifs.jar library is also needed. Although included with the original library it is posted separately here because of forum file size constraints.
     

    Attached Files:

    Last edited: Apr 29, 2013
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice