简体   繁体   中英

TClientDataset in OS X Firemonkey App

I have a Windows Firemonkey app that uses TClientDatasets to load XML data files that I'm trying to get to work on OS X. The data files are stored on a Windows file share so multiple users can access the same data (I'm not concerned about concurrency issues here).

I can't seem to get the mac version load the files from the server - it seems to automatically preppend the local path to whatever I set in the TClientDataset.Filename property.

If I copy the datafiles into the app package before starting the app, it works perfectly, so I figured I'd try to copy the files in code, but I can't get that to work either - it can't find the files on the server.

TFile.Exists('smb://<servername>/<path>/Data.xml');

Returns FALSE despite the fact I can see it in Finder.

Ideally, I'd prefer to load the files from the share rather than copy them at startup and copy back on exit.

The biggest problem is that Mac OS does not automatic map your network folder to an local folder, windows virtualy does this for you even if you don't map your drive so all files is temp copyed to a virtual space and thats why you can use it direct from your application on windows without map the network folder.

So to solve that problem you will need to mount your share to some folder using something like this:

mkdir /Volumes/WinShareName mount WinShareName "cifs://server/share"

So after that you could use the TFile.Exists('/Volumes/WinShareName/Data.xml'); Or load it directly from clientedataset.loadfromfile.

I just could'nt test it because I'm without an mac machine now but thats the main idea.

UPDATED ---- You can see more examples on how to mount an network driver here

我遇到了类似的问题,通过在Windows端创建一个tcp服务器和在客户端创建一个tcp客户端来解决这个问题..并通过流发送xml文件..就像一个魅力......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM