跨平台应用程序应将数据保存在哪里? [英] Where should cross-platform apps keep their data?

查看:96
本文介绍了跨平台应用程序应将数据保存在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将构建针对Windows,Mac和Linux的应用程序。我想知道应该将应用程序数据(例如设置等)保存在哪里。

I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.

应用程序的安装文件夹是最简单的选择,但是我认为这可能是新的Vista安全性的问题模型。此外,用户可能需要不同的设置。

Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want different settings.

C:\Documents and Settings\username\MyApp是否对Vista和XP都有用?
/ home / username / .MyApp是否适用于Linux和Mac?

Is it C:\Documents and Settings\username\MyApp good for both Vista and XP? Is it /home/username/.MyApp good for Linux and Macs?

任何想法和/或最佳做法的链接都值得赞赏。

Any ideas and/or links to best practices much appreciated.

谢谢!

胡安

推荐答案

每个平台都有其自己的API,用于查找用户的主文件夹,文档文件夹或首选项文件夹。

Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder.


  • Windows:SHGetFolderPath()或SHGetKnownFolderPath()

  • Mac OS X和iPhone OS:NSSearchPathForDirectoriesInDomains ()

  • Unix:$ HOME环境变量

不要硬编码特定路径或只是在用户名上添加前缀和后缀。另外,尝试遵循平台命名文件的所有约定。

Don't hardcode specific paths or just tack a prefix and suffix on the user's name. Also, try to follow whatever conventions there are for the platform for naming the files.

这篇关于跨平台应用程序应将数据保存在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆