B4J Question B4J Copy Paste Files

rodmcm

Active Member
Licensed User
I have used FileChoser> ShowOpenMultiple to allow the user to select a group of files that I want to then copy to a folder of my choosing.
The list items returned include the 'combined' folder path and file name. i.e.

C:\Users\McMahon\Desktop\Test3\BC230896.pdf

All of the copy/paste or file move functions I have found all seem to require separate source and target paths and separate file names to operate.
Is there are way to copy using the above 'combined' items directly or do I have to extract the source path and file name from each of the list items?
 

rodmcm

Active Member
Licensed User
Thanks Errol...
As I needed both the file and folder directory I stripped the combined file name and then used
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
If necessary, you can split the user choice as follows (add error detection if necessary):

Split folder and filename with internal libraries:
    Dim myString As String = $"C:\Users\McMahon\Desktop\Test3\BC230896.pdf"$
    Dim Parts() As String = Regex.Split("\\", myString)
    
    Dim FileName As String = Parts(Parts.Length - 1)
    Log (FileName)
    
    Dim Folder As String =myString.SubString2(0, myString.IndexOf(FileName))
    Log(Folder)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Or simpler:
B4X:
Dim Folder As String = File.GetFileParent(FullFilePath)
Dim FileName As String = File.GetName(FullFilePath)
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…