B4A Library SMB library

Last edited:
Hallo Erel,

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

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

Code: Copy
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
 
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.

Upps..:-)
Thanks Erel.

here is the correct code of DownloadCompleted:

Code: Copy
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
 
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
 
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
 
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:
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?
 
Hello,

i create a txt file with following code:

Code: Copy
            '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: Copy
[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: Copy
[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: Copy
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
 
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.
 
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.

Hallo, manios,

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

Danke für ganz schnelle Antwort.

gruss
erkaN
 
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
 
I can do this:
Code: Copy
SMB1.ListFiles(MyServer, "*.*")  'To get all files in server
But not this:
Code: Copy
SMB1.ListFiles(MyServer, "*.txt, *.tab")
Is there a way to list files for more than one extension, but not all?
Thank you
 
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.
 

Attachments

Last edited:
Back
Top