Unity文件操作——调用减压文件解压

来源:互联网 发布:网络贷款还不起怎么办 编辑:程序博客网 时间:2024/04/30 06:49

注:移动端解压文件请到如下链接——http://blog.csdn.net/aiyan1111111/article/details/52769123

 

使用Unity调用系统解压工具解压文件:
</pre></h2><p><span style="font-size:18px;"><strong>具体方法如下——直接上代码:</strong></span></p><p><span style="font-size:18px;"><strong></strong></span></p><p><span style="font-size:18px;"><strong></strong></span><pre name="code" class="html"><span style="font-size:14px;">
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);        }    }}</span>




0 0