Eugenio Monti 0 Posted August 23, 2023 I'm porting on Android an old app originally developed for Windows tablet. I use FMX on C++Builder 10.2. My problem is how to port the row: FileOpen("\\IP_address\FolderName\Filename"); I have to run app on Samsung device NOT rooted. Which is the better approach? Thanks in advance Share this post Link to post
Rollo62 536 Posted August 23, 2023 It looks as if you want to download a file via HTTP request, like this here in a German blog. Then you should use something like Indy IdHttpClient for that purpose, as a rough guess what you are looking for. Share this post Link to post
David Heffernan 2345 Posted August 23, 2023 3 minutes ago, Rollo62 said: It looks as if you want to download a file via HTTP request, like this here in a German blog. Then you should use something like Indy IdHttpClient for that purpose, as a rough guess what you are looking for. It doesn't look like that to me. It looks like a file read for a file named by UNC. I don't think I'd be wanting to use FileOpen anywhere ever. Shouldn't you be using streams these days? Having said that of course, FileOpen still works. You didn't tell us what happened when you used the old code. If you have a problem that you want some help with, then you should say what the problem is. People can't offer solutions to problems that aren't described. Do you understand what \\IP_address\FolderName\Filename is? I trust you do, and that the file specified by this UNC path is available on your current target device. Is it? 1 Share this post Link to post
Eugenio Monti 0 Posted August 23, 2023 Thanks David, I state it is an intranet application. The goal of the (old) app is to open a text file and modifiy some vales in a row. That file is present in a Samba shared folder on a customer Windows machine so "IP_address" is the IP of that machine and " FolderName " is the share name. From that machine I also have to copy some image files to a local folder of Android device and viceversa. Share this post Link to post
David Heffernan 2345 Posted August 23, 2023 2 hours ago, David Heffernan said: You didn't tell us what happened when you used the old code. If you have a problem that you want some help with, then you should say what the problem is. People can't offer solutions to problems that aren't described. Share this post Link to post
Fr0sT.Brutal 900 Posted August 23, 2023 First you have to ensure that Samba folder is accessible on Android as Samba on Linux has long history of pain and suffer. Try some advanced file manager like TC, Far etc. Share this post Link to post
Eugenio Monti 0 Posted August 23, 2023 Ok, I already made some tests. In my device I installed different file manager (Solid Explorer, RS File Manager) and all of them are able to connect the remote IP and browse folders and sub-folders. That's right...but...how can I do the same programmatically with FMX? Obviously I already tried: FileOpen("//IP_address/FolderName/Filename"); FileOpen("IP_address/FolderName/Filename"); FileOpen("smb://IP_address/FolderName/Filename"); I'm not a Linux expert but probably I should "mount" the remote connection on local filesystem; how can I do it? Share this post Link to post
David Heffernan 2345 Posted August 23, 2023 When you tried this, what happened? What error was reported. Or was there no error reported? Share this post Link to post
Eugenio Monti 0 Posted August 23, 2023 No exceptions, no errors. Simply it returns INVALID_HANDLE_VALUE. Share this post Link to post
mvanrijnen 123 Posted August 23, 2023 (edited) ... <application android:persistent="%persistent%" android:restoreAnyVersion="%restoreAnyVersion%" android:label="%label%" android:debuggable="%debuggable%" android:largeHeap="%largeHeap%" android:icon="%icon%" android:theme="%theme%" android:hardwareAccelerated="%hardwareAccelerated%"> <!-- **** ADD THIS SECTION **** --> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.embarcadero.yourAppName.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider> <%application-meta-data%> <%services%> ... Take a look here: Delphi Android file open failure with API 26 - Stack Overflow? maybe hat works, and maybe you first have to ask access with credentials? editing goes wrong in the forum sometimes 🙂 Edited August 23, 2023 by mvanrijnen Share this post Link to post
David Heffernan 2345 Posted August 23, 2023 22 minutes ago, Eugenio Monti said: No exceptions, no errors. Simply it returns INVALID_HANDLE_VALUE. Well, there will be an error code. You have to retrieve it. Share this post Link to post