' --- This program reuires:
' --- A file share with the name TempDir
' --- Libraries: jShell (internal)
#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
Private Page As Form
Private fc As FileChooser
Private DirPath As String
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
fc.Initialize
FindShare
fc.InitialDirectory = DirPath
fc.SetExtensionFilter("Layouts",Array("*.*"))
fc.Title = "Open Share"
End Sub
Private Sub Button1_Click
FindShare
Dim f As String = fc.ShowOpen(Page)
' --- process result
If f <> Null Then Log(f)
End Sub
Sub FindShare As ResumableSub
Dim shl As Shell
shl.Initialize("shl", "wmic", Array("share", "TempDir", "get", "Path"))
shl.Run(-1)
Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success Then
Dim x As Int = 0
For Each line As String In Regex.Split("[\r\n]+", StdOut)
If x = 1 Then '--- We need second result value
Dim fc As FileChooser
fc.Initialize
fc.InitialDirectory = line.Trim
DirPath = line.Trim
Return line.Trim
End If
x = x+1
Next
End If
Return ""
End Sub