How to read a string file?

Hello,

For my C application, i need to read a string file located at /home/root/data.txt (get file contents to a char variable).
After many tries, i not found how to do this.
Can anyone give me an example to how to accomplish this ?

Thanks !

Please see https://forum.legato.io/t/file-read-and-write-in-legato-18-09-0/3824

1 Like

Hi @pierre.josselin,
If your application is sandboxed, your file is then located in “/legato/system/current/appsWritable/yourApp/home/root/data.txt”.
If you need to access this file, absolute path, then your app should be unsandboxed (config in adef is sandboxed : false).

Hope this helps
Nhon

Thank you for your answers, I will try this.