Android Question Move a .txt file from device memory to a network drive/folder.

Nefeco

Member
Licensed User
I need to move a .txt file from device memory to external storage - a network (NAS) drive which is on the same network as the device on which the App is running. The network/NAS drive is running whatever cut-down Linux Western Digital NAS drives run.

Is this something for FTPUpload or is there a better/easier way? And, if it's FTPUpload will I need to run/initiate/configure a/the FTP server on the NAS.

Grateful for any advice, examples etc...

Thanks in advance,

N.
 

Nefeco

Member
Licensed User
So I've set up the FTP server on my NAS drive and it works (tested with cmd > ftp > put).

Programmatically I'm trying:

Dim FileMover As FTP
FileMover.Initialize("FTP","192.168.1.164",22,"<username>","<pwd>") 'Username & pwd same as in sucessful cmd > ftp > put test
FileMover.PassiveMode = True
FileMover.UseSSL = False
:
:
FileMover.UploadFile(File.DirRootExternal, "LALog.txt",False, "‪\\WDMYCLOUD\Public\LALogs\TestLALog.txt")

Which silently fails.

What obvious (but not to me!) blooper am I making?

Thanks,

--N.
 
Upvote 0

Nefeco

Member
Licensed User
Thanks.

The last thing I need my App to do is FTP.UploadFile a file (code below). I try to do this in the Activity_Keypress that handles the back key being pressed.

The inclusion of the Wait For (sf) line forces the Activity_Keypress to change from Boolean to ResumableSub.

What am I not understanding? How should I be trying to achieve this?

Thanks,

--N.

B4X:
Sub Activity_Keypress (KeyCode As Int)As Boolean
   If KeyCode = KeyCodes.KEYCODE_BACK Then
       If Msgbox2("Exit?", "", "Yes", "", "No", Null) = DialogResponse.POSITIVE Then
           :
           Dim FileMover As FTP
           FileMover.Initialize("FTP","192.168.1.164",22,"xxx","xxx")
           FileMover.PassiveMode = True
           FileMover.UseSSL = False
           :
           Dim ServerPath As String = "\\WDMYCLOUD\Public\LALogs"
           Dim Success As Boolean = False
         
           Dim sf As Object = FileMover.UploadFile(File.DirRootExternal, "LALog.txt", False, "\\WDMYCLOUD\Public\LALogs\LALogTest1.txt")
           Wait For (sf) ftp_UploadCompleted (ServerPath As String, Success As Boolean)
        
           Msgbox("Session Ending - please wait", "Session Ending")
         
           LogFile.Close()
           Return False
           ExitApplication
       Else
           Return True
       End If
   Else
       Return False
   End If
End Sub
 
Last edited:
Upvote 0

Nefeco

Member
Licensed User
Ta.

If the Wait For... returns failure, how do I "see inside" it (or inside the .UploadFile... ) to work out what exactly failed...?

--N.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…