B4XFileUtils is a code module added to B4XCollections library. It holds various methods related to files and paths.
A path in this context is a combination of the folder and optionally a file name.
Use File.Combine to combine a folder and file name to a single path. The other way from a path to a separate folder and file name is possible with B4XFileUtils methods, however it is usually not needed. You simply need to pass the full path in the "dir" parameter:
Example:
Dim Path As String = File.Combine(XUI.DefaultFolder, "File1.txt")
Dim s As String = File.ReadString(Path, "") 'leave the FileName parameter empty.
Note that most of these methods will not work with File.DirAssets.
Methods:
Name - Returns the file or folder name.
NameWithoutExtension - Returns the name without extension.
Extension - Returns the file extension.
ReplaceExtension - Replaces (or adds if none) the path extension and returns the new path (doesn't modify the actual file).
Parent - Returns the file or folder parent.
Rename - Renames a file or folder. Can also be used to move a file.
CopyFolder - Copies all files and optionally subfolders (recursive).
DeleteFolder - Deletes a folder and optionally subfolders (recursive).
ListFilePlus - List files and folders, optionally recursive. Can filter by zero or more (case insensitive) file extensions. Returns a list of full paths.
RealPath (B4A, B4J) - Returns the canonical path. Resolves symlinks.
Example - for some reason we want to replace all zip files extensions to tar:
Dim ZipFiles As List = B4XFileUtils.ListFilesPlus("C:\Users\H\Example", True, Array("zip"))
For Each path As String In ZipFiles
Dim NewPath As String = B4XFileUtils.ReplaceExtension(path, "tar")
B4XFileUtils.Rename(path, NewPath)
Next