MonoTouch 在 iOS 上定义的一些特殊目录

Environment.SpecialFolder

通过对 Environment.SpecialFolder 进行枚举, 可以得到 MonoTouch 在 iOS 设备上定义的特殊目录列表如下:

SpecialFolder iOS 模拟器# iOS 设备
Desktop #/Applications/{appid}/Desktop /private/var/mobile/Applications/{appid}/Desktop
Personal #/Applications/{appid}/Documents /private/var/mobile/Applications/{appid}/Documents
Favorites #/Applications/{appid}/Library/Favorites /private/var/mobile/Applications/{appid}/Library/Favorites
MyMusic #/Applications/{appid}/Music /private/var/mobile/Applications/{appid}/Music
MyVideos #/Applications/{appid}/Videos /private/var/mobile/Applications/{appid}/Videos
DesktopDirectory #/Applications/{appid}/Desktop /private/var/mobile/Applications/{appid}/Desktop
Templates #/Applications/{appid}/Templates /private/var/mobile/Applications/{appid}/Templates
ApplicationData #/Applications/{appid}/Documents/.config /private/var/mobile/Applications/{appid}/Documents/.config
LocalApplicationData #/Applications/{appid}/Documents /private/var/mobile/Applications/{appid}/Documents
InternetCache #/Applications/{appid}/Library/Caches /private/var/mobile/Applications/{appid}/Library/Caches
CommonApplicationData /usr/share /usr/share
ProgramFiles /Applications /Applications
MyPictures #/Applications/{appid}/Pictures /private/var/mobile/Applications/{appid}/Pictures

# 表示 iOS 模拟器根目录, 通常为 ~/Library/Application Support/iPhone Simulator/5.0

Environment.CurrentFolder

在程序中调用 Environment.CurrentFolder , 在 iOS 模拟器上, 得到的值为 #/Applications/{appid}/{AppName}.app , 在 iOS 设备商, 得到的值是 /private/var/mobile/Applications/{appid}/{AppName}.app 。

IsolatedStorage

在 iOS 上也使用 IsolatesStorage 与 Silverlight 大致相同, 不过iOS 上的本地存储只支持用户存储, 不支持机器独立存储, 也就是说只能使用下面三个方法是用本地存储:

  • IsolatedStorageFile.GetUserStorage()
  • IsolatedStorageFile.GetUserStoreForAssembly()
  • IsolatedStorageFile GetUserStoreForDomain()

通过跟踪发现, 这几个方法是用的独立存储目录是一样的, 都是存取 Environment.SpecialFolder.ApplicationData 目录。

posted @ 2012-02-26 20:16  张志敏  阅读(869)  评论(0编辑  收藏  举报