unity3d 压缩文件夹和压缩文件
来源:互联网 发布:shake it of 编辑:程序博客网 时间:2024/06/04 19:50
直接开始,不扯淡
1:下载名字为《 Ionic.zip 》的压缩包,将里面的《 Ionic.Zip.dll 》放到unity3d的Plugins文件夹下。如果没有此文件夹,自己创建
2:脚本操作
using UnityEngine;
using System.Collections;
using Ionic.Zip;
public class YaSuo : MonoBehaviour {
//路径
string WenJianJiaPath; //文件夹
//string FilePath; //文件
// Use this for initialization
void Start () {
//设置文件夹的路径
WenJianJiaPath = Application.dataPath + "/Sound";
//文件路径
//FilePath = Application.dataPath + "/Sound/New Material.mat";
//压缩包的名字
string FileName = "XiaoBaiYaSouFile";
//输出
print(FileName);
//开始压缩
using(ZipFile zip = new ZipFile(Application.dataPath + "/" + FileName + ".zip")){
//设置密码
zip.Password = "000";
//压缩文件夹
zip.AddDirectory(WenJianJiaPath, "Sound");
//压缩文件
//zip.AddFile(FilePath,"");
//保存
zip.Save();
//其他方法提示
//删除文件
//zip.RemoveEntry();
//解压文件
//zip[text.text].Extract(SoundPath);
}
}
}
3:此脚本随便拖到一个物体上。
4:创建一个Sound的文件夹,因为脚本上面我填写的就是Sound文件夹。zip.AddDirectory(WenJianJiaPath, "Sound");
5:运行程序。
温馨提示:
如果有中文路径,请将 using(ZipFile zip = new ZipFile(Application.dataPath + "/" + FileName + ".zip")) 改成 using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))
然后将 zip.Save(); 改成 zip.Save(Application.dataPath + "/" + FileName + ".zip");
这样就完美的解决了发布以后中文文件夹名字变成乱码的情况啦。
- unity3d 压缩文件夹和压缩文件
- Java压缩文件夹和压缩文件代码:
- Unity3D压缩和解压缩文件
- java 压缩文件,文件夹,和解压缩文件夹
- SharpZipLib压缩文件和文件夹
- JAVA压缩文件夹,批量压缩文件(夹)
- .net压缩文件夹及下载压缩文件
- 压缩文件的压缩和解压
- Java 解压和压缩文件(文件夹)
- c#解压压缩文件和文件夹
- Unity3d压缩文件
- Java将指定文件/文件夹压缩成zip、rar压缩文件
- 将指定文件/文件夹压缩成zip、rar压缩文件
- SharpZipLib 压缩多个文件去掉压缩文件中的目录文件夹
- linux下常用压缩文件和压缩命令
- Linux下常见压缩文件 压缩和解压
- C#中实现压缩文件和文件夹
- C#中实现压缩文件和文件夹 .
- 160715_发现md文档是一个很有趣的新奇玩意儿!
- 3JSP与Javabean
- 生成随机验证码
- 【旧代码整理】做的一个简单的php mvc框架
- Java解析XML文件的四种方法
- unity3d 压缩文件夹和压缩文件
- android listview 异步加载图片并防止错位
- Sum of Two Integers
- 操作系统知识总结.
- 4文件上传与下载
- UML 符号说明
- Ubuntu14.04 Torch Configuration
- 【Spring 2】spring的属性注入形式
- too many open files