Android Question [B4XPages] convert HttpServer example, but "List external storage files" no function

a6000000

Member
Licensed User
Longtime User
I try move HttpServer example to B4X

all ok but

List external storage files

no function:

Cannot access folder.

in line 89 in ServerService


I copy from original HttpServer Example to new B4X project File B4XMainPage:


B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
   
    'copy from original example HttpServer:
    'modify Dim in Globals to Private in Class_Globals
    Private lblIP As Label
    Private EditText1 As EditText
   
End Sub

Public Sub Initialize
   
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
   
    'copy from original example HttpServer:
    Root.LoadLayout("1")
    Dim ssocket As ServerSocket
    Log("Ip address: " & ssocket.GetMyWifiIP)
    If ssocket.GetMyWifiIP = "127.0.0.1" Then
        lblIP.Text = "Device not connected to local network"
    Else
        lblIP.Text = "Device address: " & ssocket.GetMyWifiIP & ":" & ServerService.port
    End If
    If File.Exists(File.DirInternal, "greeting.txt") Then
        EditText1.Text = File.ReadString(File.DirInternal, "greeting.txt")
        ServerService.greeting = EditText1.Text
    End If
   
   
   
   
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

'delete Sub Button1_Click
'copy from original example HttpServer:
'add ServerService.bas as add existing Modules
'in folder B4A over folder Files, same Folder where *.b4a and Starter.bas
'add Files list_template.html , main_template.html in Files Dir
'change config to Package b4a.HttpServerX50
'in Main change #ApplicationLabel: HttpServerX50
'no happy: List external storage files: error: Cannot access folder.
'do I need here Activity_Resume ??:  or delete: ??
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    File.WriteString(File.DirInternal, "greeting.txt", ServerService.greeting)
End Sub

Sub btnStart_Click
    StartService(ServerService)
End Sub

Sub btnStop_Click
    StopService(ServerService)
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
    ServerService.greeting = New
End Sub
 

a6000000

Member
Licensed User
Longtime User
Log("Error serving request: " & LastException) in line 48

but the original example HttpServer is ok.
 
Last edited:
Upvote 0
Top