Beispiel #1
0
    IEnumerator DoResUpdate(int verResLocal, int verResServer)
    {
        if (verResLocal >= verResServer)
        {
            _taskUpdateNum--;
        }
        else
        {
            verResLocal++;
            string resFile = Config.ApiUrl + "res/" + Config.platform + "/" + verResLocal + ".zip";

            WWW wwwRes = new WWW(resFile);
            yield return(wwwRes);

            if (!string.IsNullOrEmpty(wwwRes.error))
            {
                Debug.LogError("request " + resFile + " error: " + wwwRes.error);
                yield break;
            }

            string localResFile = Config.ResPath + "res.zip";
            File.WriteAllBytes(localResFile, wwwRes.bytes);

            UtilZip.UnZip(localResFile, Config.ResPath);

            File.Delete(localResFile);
            SetLocalResVersion(verResLocal);
            StartCoroutine(DoResUpdate(verResLocal, verResServer));
        }
    }
Beispiel #2
0
    void Start()
    {
        _zipSrcPath  = Application.dataPath + "/Examples/Zip/Src/";
        _zipSrcFile  = Application.dataPath + "/Examples/Zip/Src.zip";
        _zipDestPath = Application.dataPath + "/Examples/Zip/Dest/";

        Dictionary <string, string> dictFile = new Dictionary <string, string>();

        DirectoryInfo dirInfo = new DirectoryInfo(_zipSrcPath);

        FileInfo[] filesInfo = dirInfo.GetFiles("*", SearchOption.AllDirectories);
        for (int i = 0; i < filesInfo.Length; i++)
        {
            var fileInfo = filesInfo[i];
            if (fileInfo.Name.EndsWith(".meta"))
            {
                continue;
            }
            Debug.Log("fileInfo.FullName: " + fileInfo.FullName);
            string relativeName = fileInfo.FullName.Substring(_zipSrcPath.Length);
            Debug.Log("relativeName:" + relativeName);
            dictFile.Add(fileInfo.FullName, relativeName);
        }

        UtilZip.Zip(dictFile, _zipSrcFile);

        UtilZip.UnZip(_zipSrcFile, _zipDestPath);
    }