LWGShane Well-Known Member Licensed User Longtime User Apr 27, 2016 #1 I have a FileChooser which is set to ShowOpenMultiple() and returns the files to a list. However, I'm unsure how to handle the list items in the File.Copy or File.Copy2 methods due to each needing a directory. Thanks, CBL.
I have a FileChooser which is set to ShowOpenMultiple() and returns the files to a list. However, I'm unsure how to handle the list items in the File.Copy or File.Copy2 methods due to each needing a directory. Thanks, CBL.
Erel B4X founder Staff member Licensed User Longtime User Apr 28, 2016 #2 Are you copying all files to the same folder? You can use this code to get the file name: Code: Copy Sub GetFileName(fullpath As String) As String Dim i As Int = fullpath.LastIndexOf("\") If i = -1 Then i = fullpath.LastIndexOf("/") If i = -1 Then Return fullpath If i = fullpath.Length - 1 Then Return "" Return fullpath.SubString(i + 1) End Sub Code: Copy Dim files As List = fc.ShowOpenMultiple(MainForm) If files.IsInitialized Then For Each f As String In files File.Copy(f, "", <target>, GetFileName(f)) Next End If Upvote 0
Are you copying all files to the same folder? You can use this code to get the file name: Code: Copy Sub GetFileName(fullpath As String) As String Dim i As Int = fullpath.LastIndexOf("\") If i = -1 Then i = fullpath.LastIndexOf("/") If i = -1 Then Return fullpath If i = fullpath.Length - 1 Then Return "" Return fullpath.SubString(i + 1) End Sub Code: Copy Dim files As List = fc.ShowOpenMultiple(MainForm) If files.IsInitialized Then For Each f As String In files File.Copy(f, "", <target>, GetFileName(f)) Next End If