首先,看文档:

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目录下的文件的更多相关文章

  1. IO流-获取指定目录下文件夹和文件对象【File类】

    一.运用File类实现获取指定目录下文件夹和文件对象 1.File类 2.方法: 获取文件绝对路径 :getAbsolutePath 案例: import java.io.File; /** * 获取 ...

  2. IIS目录下文件共享后System.IO.File.Exists返回false

    场景:在iis目录下,因为特殊需要共享一个文件夹,给到其他的技术人员访问,突然发现小小的操作,搞“大”了,使用 string path = Server.MapPath("~/file/te ...

  3. 详解C#中System.IO.File类和System.IO.FileInfo类的用法

    System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间.下面通过程序实例来介绍其主要属性和方法. (1) 文件打开 ...

  4. System.IO.File.Create 不会自动释放,一定要Dispose

    这样会导致W3P进程一直占用这个文件 System.IO.File.Create(HttpContext.Current.Server.MapPath(strName)) 最好加上Dispose Sy ...

  5. System.IO.File.WriteAllText("log.txt", "dddd");

    System.IO.File.WriteAllText("log.txt", "dddd");

  6. System.IO.File类和System.IO.FileInfo类

    1.System.IO.File类 ※文件create, copy,move,SetAttributes,open,exists ※由于File.Create方法默认向所有用户授予对新文件的完全读写. ...

  7. 关于 System.IO.File.Exists 需要注意的事项

    各位:   .NET Framework 本省在设计的时候,他对于异常没有完全做到抛出,这样可能会有很多意想不到的问题.   比如 你在asp.net 应用程序中判断文件是否存在,这个文件可能是一个共 ...

  8. 如何在安卓/data(而不是/data/data)目录下进行文件的读写操作

    分析:Android默认是无法直接操作/data目录的,只能读写程序自己的私有目录,也就是/data/data/package name/下,默认只能操作这个目录下的文件,也就是我们想直接读写/dat ...

  9. java-IO流(File对象-深度遍历指定目录下的文件夹和文件)

    需求:遍历这个树状结构 File(String pathname) '\\'为了转义'\' // 通过抽象路径pathname 创建一个新的文件或者目录 File parent = new File( ...

随机推荐

  1. json包含单双引号问题解决方案

    解决方案:在后台处理 JSONArray.fromObject(list).toString() 转自明明如月小角落: 效果DEMO: JsonQuotesUtil.js /** * 解决json传输 ...

  2. linux sh文件提示 no such file or directory

    Linux执行.sh文件,提示No such file or directory的问题的解决方法 12-06-28 16:59作者:love__coder Linux执行.sh文件,提示No such ...

  3. Eclipse设置相同变量背景色高亮显示

    在Eclipse中,鼠标选中或者光标移动到java类的变量名时,相同变量会被标识显示(设置背景色高亮), 并且侧边滚动条会标出变量的位置, 查找变量十分方便. 1.相同变量标识高亮显示: Window ...

  4. bzoj1825: [JSOI2010]蔬菜庆典

    Description Input Output 对于每组数据,输出一行.若蔬菜的总价能无限制增大,输出"+inf"(不含引号).否则输出一个整数,表示所有蔬菜的最大总价.   首 ...

  5. js轮播插件

    // Tween算法 var Tween = { // t:当前步数 // b:初始位置 // c:总距离 // d:总步数 // Linear:匀速 Linear: function(t,b,c,d ...

  6. 动画js版本

    动画: 1)css样式提供运动 2)js提供的运动 过渡的属性:transition 从一种情况到另一种情况叫过渡 transition:变化的属性  (attr) transition:花费的时间  ...

  7. 1070 Mooncake (25 分)

    1070 Mooncake (25 分) Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn ...

  8. 最小化Linux系统安装

    安装CentOS 5.9 基于vbox虚拟机,虚拟机内存1 G,虚拟硬盘大小8 G 虚拟网卡使用host only方式 创建卷组centos 独立的boot分区 home, root和swap分区皆是 ...

  9. HP-UX oracle RAC 双机实践 (转载)

    一.软硬件配置检查 1.检查内存#/usr/contrib/bin/machinfoCPU info:  4 Intel(R) Itanium 2 9100 series processors (1. ...

  10. Spark分析之MemoryStore

    private case class MemoryEntry(value: Any, size: Long, deserialized: Boolean) class MemoryStore(bloc ...