Android Question Copy files to a share folder on LAN

ptb_eta

Member
Good morning everyone
as per the title I have to copy a text file from my Android app to a shared folder on a Windows local network to which I am connected in wifi.
It's been a while that I've been banging my head with the various SMB, SMB2 and jcifs, both reading here on the forum and from other sources but I haven't come to the conclusion.
So to you who have more experience I ask two things: do you have a clear and working example to show me?
Or can you suggest another way to achieve the goal?

Thanks in advance,
Paul
 

d3vc

Member
Good morning everyone
as per the title I have to copy a text file from my Android app to a shared folder on a Windows local network to which I am connected in wifi.
It's been a while that I've been banging my head with the various SMB, SMB2 and jcifs, both reading here on the forum and from other sources but I haven't come to the conclusion.
So to you who have more experience I ask two things: do you have a clear and working example to show me?
Or can you suggest another way to achieve the goal?

Thanks in advance,
Paul
Copy file to a shared folder:
'  don't forget to set the right permissions in your manifest file .

Sub CopyFileToSharedFolder(FileName As String, SharedFolderPath As String)
    Dim SourceFile As String = File.DirRootExternal & "/" & FileName
    Dim DestinationFile As String = SharedFolderPath & "/" & FileName

    If File.Exists(SourceFile) Then
        File.Copy(SourceFile, DestinationFile)
        Log("File copied to shared folder: " & DestinationFile)
    Else
        Log("Source file does not exist: " & SourceFile)
    End If
End Sub

B4X:
' usage

    CopyFileToSharedFolder("example.txt", "\\192.168.1.100\SharedFolder")
 
Upvote 0

ptb_eta

Member
Tip: whenever you see code with File.DirRootExternal you immediately know that it is broken.

It is also impossible to directly access a network folder like this.

You will need to use SMB or SMB2 libraries.

I tried to use SMB2 but I haven't found complete and working examples so far, does anyone have any?
 
Upvote 0
Top