安卓上为什么不能用system.io.file读取streammingAssets目录下的文件
首先,看文档:
Streaming Assets
Most assets in Unity are combined into the project when it is built. However, it is sometimes useful to place files into the normal filesystem on the target machine to make them accessible via a pathname. An example of this is the deployment of a movie file on iOS devices; the original movie file must be available from a location in the filesystem to be played by the PlayMovie function.
Any files placed in a folder called StreamingAssets (case-sensitive) in a Unity project will be copied verbatim to a particular folder on the target machine. You can retrieve the folder using the Application.streamingAssetsPathproperty. It’s always best to use Application.streamingAssetsPath to get the location of the StreamingAssets folder, as it will always point to the correct location on the platform where the application is running.
The location of this folder varies per platform. Please note that these are case-sensitive:
On a desktop computer (Mac OS or Windows) the location of the files can be obtained with the following code:
path = Application.dataPath + "/StreamingAssets";
On iOS, use:
path = Application.dataPath + "/Raw";
On Android, use:
path = "jar:file://" + Application.dataPath + "!/assets/";
On Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file.
Note: .dll files located in the StreamingAssets folder don’t participate in the compilation.
总结:在安卓上,streamingAssets目录是在一个jar压缩包中,路径为:path = "jar:file://" + Application.dataPath + "!/assets/"; 因为jar是压缩包,因此不能使用普通的文件读取方式,WWW带解压功能,可以使用它
安卓上为什么不能用system.io.file读取streammingAssets目录下的文件的更多相关文章
- IO流-获取指定目录下文件夹和文件对象【File类】
一.运用File类实现获取指定目录下文件夹和文件对象 1.File类 2.方法: 获取文件绝对路径 :getAbsolutePath 案例: import java.io.File; /** * 获取 ...
- IIS目录下文件共享后System.IO.File.Exists返回false
场景:在iis目录下,因为特殊需要共享一个文件夹,给到其他的技术人员访问,突然发现小小的操作,搞“大”了,使用 string path = Server.MapPath("~/file/te ...
- 详解C#中System.IO.File类和System.IO.FileInfo类的用法
System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间.下面通过程序实例来介绍其主要属性和方法. (1) 文件打开 ...
- System.IO.File.Create 不会自动释放,一定要Dispose
这样会导致W3P进程一直占用这个文件 System.IO.File.Create(HttpContext.Current.Server.MapPath(strName)) 最好加上Dispose Sy ...
- System.IO.File.WriteAllText("log.txt", "dddd");
System.IO.File.WriteAllText("log.txt", "dddd");
- System.IO.File类和System.IO.FileInfo类
1.System.IO.File类 ※文件create, copy,move,SetAttributes,open,exists ※由于File.Create方法默认向所有用户授予对新文件的完全读写. ...
- 关于 System.IO.File.Exists 需要注意的事项
各位: .NET Framework 本省在设计的时候,他对于异常没有完全做到抛出,这样可能会有很多意想不到的问题. 比如 你在asp.net 应用程序中判断文件是否存在,这个文件可能是一个共 ...
- 如何在安卓/data(而不是/data/data)目录下进行文件的读写操作
分析:Android默认是无法直接操作/data目录的,只能读写程序自己的私有目录,也就是/data/data/package name/下,默认只能操作这个目录下的文件,也就是我们想直接读写/dat ...
- java-IO流(File对象-深度遍历指定目录下的文件夹和文件)
需求:遍历这个树状结构 File(String pathname) '\\'为了转义'\' // 通过抽象路径pathname 创建一个新的文件或者目录 File parent = new File( ...
随机推荐
- 3d之ui快速切换图像
Requirement canon相机continuous mode(Burst mode) 抓图variation (230~320ms) 1. python + opencv 用cvWaitKey ...
- java初始化块执行顺序
java中初始化块的执行顺序在构造器之前,多个初始化块之间定义在前的先执行.如下: public class InitialBlockTest { // The first one { System. ...
- 使用scrapy框架爬取自己的博文
scrapy框架是个比较简单易用基于python的爬虫框架,http://scrapy-chs.readthedocs.org/zh_CN/latest/ 这个是不错的中文文档 几个比较重要的部分: ...
- 【python】class之super关键字的作用
在Python类的方法(method)中,要调用父类的某个方法,在Python 2.2以前,通常的写法如代码段1: 代码段1: class A: def __init__(self): prin ...
- git Push failed: Could not read from remote repository 解决方案
解决的办法很简单,进入Android Studio配置界面,选择Version Control——>Git,在右边界面切换SSH下拉选项为Native,最后重新提交.如果解决你的问题,记得分享哦 ...
- vue+node+mongoDB前后端分离个人博客(入门向)
最近学习了VUE,自己为了学习做了个小小的博客,功能很简单,不过开发过程中也遇到了很多坑,所以记录下来方便以后使用.欢迎大家交流学习. 功能 实现了用户注册.登录.token检测登录.用户留言.个人中 ...
- Hadoop高级培训课程大纲-管理员版
一.课程概述 本次培训课程主要面向大数据系统管理人员和开发设计人员,基于开源社区大数据应用最活跃的Hadoop和HBase技术框架.围绕分布式文件存储(HDFS).分布式并行计算(Map/Recue) ...
- bzoj1876 SuperGCD
Description Sheng bill有着惊人的心算能力,甚至能用大脑计算出两个巨大的数的GCD(最大公约 数)!因此他经常和别人比赛计算GCD.有一天Sheng bill很嚣张地找到了你,并要 ...
- shell脚本判断语句和循环语句
if判断语句 exit跳出判读语句 不加exit的结果 read -n(不换行) 判断是否输入的是数字 read age[[ $age =~ ^[0-9]+$ ]]if [ $? -ne 0 ]; t ...
- How to use POST method in Tornado?
http://stackoverflow.com/questions/10367981/how-to-use-post-method-in-tornado