您的位置:首页 > 移动开发 > Unity3D

Unity3D调用7z解压文件

2013-11-22 15:49 645 查看
原文地址

using UnityEngine;
using System;
using System.IO;
using System.Diagnostics;

public class Test : MonoBehaviour
{
    //7z程序的程序目录
    private string _7zExeUrl ;

    void Start()
    {
        _7zExeUrl = Application.dataPath + "/StreamingAssets/7z.exe";
        DecompressFileToDirectory(Application.dataPath + "/StreamingAssets/test.zip", Application.dataPath + "/StreamingAssets/");
    }

    public void DecompressFileToDirectory(string inFileath, string outFilePath)
    {
        try
        {
            Process process = new Process();
            string info = " x " + inFileath + " -o" + outFilePath + " -r ";
            ProcessStartInfo startInfo = new ProcessStartInfo(_7zExeUrl, info);
            process.StartInfo = startInfo;
            //隐藏DOS窗口  
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.Start();
            process.WaitForExit();
            process.Close();
        }
        catch (Exception e)
        {
            UnityEngine.Debug.Log(e);
        }
        
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: