iOS Question Save file to my app

ilan

Expert
Licensed User
Longtime User
hi

i am using this code to open external files in my app but i am not able to save the file.
it looks like that when Application_Openurl is raised the external file is in my DirTemp folder although when i check with file.exits() i am getting FALSE.
i want to copy the external file to my DirDocuments folder. is that possible?

thanx
 

ilan

Expert
Licensed User
Longtime User
ok i found a solution. i use Stringutils to decode the url to string. i dont know if this is the correct way but it works fine

B4X:
Private Sub Application_OpenUrl (Url As String, Data As Object) As Boolean
    If Url.StartsWith("file://") Then
        Dim f As String = Url.SubString(7) 'remove the file:// scheme.
        Dim su As StringUtils
        Dim newfile As String  = su.DecodeUrl(f, "utf8")
        Dim filename As String  = newfile.SubString2(newfile.LastIndexOf("/")+1,newfile.Length)
        
        If File.Exists("",newfile) Then
            File.Copy("",newfile,File.DirDocuments, "importfiles/" & filename)
            openimport(False)
        End If
    End If
    Return True
End Sub
 
Upvote 0
Top