B4J Question Select a directory

Daestrum

Expert
Licensed User
Longtime User
It's a bit of an ambiguous question, can you give an example of where you want to select a directory?
 
Upvote 0

samperizal

Active Member
Licensed User
Longtime User
What you want is to select a source directory and a destination directory and move all files from the source to the destination.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If it just one level of directory then you can use something like

B4X:
Dim srcDir as String = "C:/temp/someFolder"
Dim destDir as String = "C:/temp/someOtherFolder"  ' this must exist for the copy to work
Dim srcFiles as List = File.ListFiles(srcDir)
For Each f As String In srcFiles
    File.Copy(srcDir, f, destDir, f)
Next

If there are directories within the srcDir you want to copy, then you need to detect if f is a directory (File.IsDirectory(srcDir,f) and code accordingly (eg recursively read the sub directories)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Use DirectoryChooser
B4X:
Dim DC As DirectoryChooser
    DC.Initialize
    DC.InitialDirectory = 'Directory you want to start the chooser (Optional)
    Dim Folder As String = DC.Show(MainForm)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…