B4A Library SMB library

Last edited:

kaplanerkan

Member
Licensed User
Longtime User
Hallo Erel,

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

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

B4X:
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
 

kaplanerkan

Member
Licensed User
Longtime 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.

Upps..:)
Thanks Erel.

here is the correct code of DownloadCompleted:

B4X:
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
 

dmtulsa

Member
Licensed User
Longtime 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
 

hennemarc

Member
Licensed User
Longtime 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
 

hennemarc

Member
Licensed User
Longtime 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:

hennemarc

Member
Licensed User
Longtime 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?
 

kaplanerkan

Member
Licensed User
Longtime User
Hello,

i create a txt file with following code:

B4X:
            '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:

B4X:
[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:
B4X:
[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

B4X:
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
 

manios

Active Member
Licensed User
Longtime 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.
 

kaplanerkan

Member
Licensed User
Longtime 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.

Hallo, manios,

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

Danke für ganz schnelle Antwort.

gruss
erkaN
 

HotShoe

Well-Known Member
Licensed User
Longtime 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
 

Mahares

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

agraham

Expert
Licensed User
Longtime 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.
 

Attachments

  • jcifs1.3.17.zip
    362.7 KB · Views: 2,083
  • SMB1.1.zip
    34.4 KB · Views: 2,147
Last edited:
Top