安卓上为什么不能用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( ...
随机推荐
- java 多线程之:join() 方法
join()介绍 join() 定义在java.lang.Thread中. join() 的作用:让"主线程"等待"子线程"结束之后才能继续运行.
- Python与机器学习
pandas里面的对于数据操作比如where,drop以及dropna等都会有一个属性:inplace,这个单词意思是原地,如果inplace=true代表数据本身要返回(原地数据也会被改变):如果i ...
- ASP.NET Core 2.0 使用支付宝PC网站支付实现代码(转)
最近在使用ASP.NET Core来进行开发,刚好有个接入支付宝支付的需求,百度了一下没找到相关的资料,看了官方的SDK以及Demo都还是.NET Framework的,所以就先根据官方SDK的源码, ...
- 更改默认打开wifi功能
一.打开以下目录 /home/tingpan/openwrt/barrier_breaker/package/kernel/mac80211/files/lib/wifi 找到mac80211.sh ...
- 【appium】根据xpath定位元素
1. 背景 本文尝试使用的试验对象是SDK自带的NotePad应用实例,假设已经有两个Notes分别是“note1”和“note2”添加到Notepad上面,我们要做的就是尝试用xpath的方法来定位 ...
- PMP学习笔记
PMI:Project Management Institute,项目管理协会于1969年在美国成立,致力于全球范围内的项目管理研究.标准制定和出版.价值倡导.职业认证和学位 课程认证.现在,PMI已 ...
- jquery dataTable的学习
http://www.cnblogs.com/nier/archive/2012/03/19/2406450.html 分页 bPaginite:true;是否启用分页功能 sPaginationTy ...
- Android之WebViewClient与WebChromeClient的区别
Android之WebViewClient与WebChromeClient的区别 2012-05-05 0个评论 收藏 我要投稿 ANDROID应用开发的时候可能会用到WE ...
- BASIC-15_蓝桥杯_字符串对比
示例代码: #include <stdio.h>#define N 10 int main(void){ int i = 0 ; int len1 = 0 , len2 = 0 , fla ...
- mac电脑链接安卓手机的方法
https://blog.csdn.net/liubin9043/article/details/78928253/ 我用了个爱莫 不错 http://web.airmore.com