Ejemplo n.º 1
0
    /// <summary>
    /// 获得更新的资源 打包
    /// </summary>
    /// <param name="assetPath">资源路径</param>
    public static string GetUpdateRes(string assetPath, List <string> updatelist)
    {
        string dir       = "androidRes";//manifest文件
        string UpdateRes = Path.Combine(PathHelp.GetExportPath(), "UpdateRes");

        if (Directory.Exists(UpdateRes))
        {
            Directory.Delete(UpdateRes, true);
        }
        Directory.CreateDirectory(UpdateRes);
        string[] assetsName = Directory.GetFiles(assetPath);
        foreach (var item in assetsName)
        {
            string tempFile = item.Substring(item.LastIndexOf("\\") + 1);
            if (tempFile.Contains(dir))
            {
                File.Copy(item, Path.Combine(UpdateRes, tempFile));
                continue;
            }
            foreach (var name in updatelist)
            {
                if (tempFile.Contains(name.ToLower()))
                {
                    File.Copy(item, Path.Combine(UpdateRes, tempFile));
                }
            }
        }
        updatelist.ForEach(o => Debug.Log("资源更新---" + o));
        return(UpdateRes);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 更新版本号
    /// </summary>
    /// <param name="zipPath">打包资源压缩路径</param>
    /// <returns>打包资源存储路径</returns>
    private static string WriteVersionToLocal(out string zipPath, out string zipContent)
    {
        zipPath    = string.Empty;
        zipContent = string.Empty;
        string exportPath = PathHelp.GetExportPath();
        string assetPath  = Path.Combine(exportPath, "androidRes");
        string version    = Path.Combine(exportPath, "version.txt");

        if (Directory.Exists(assetPath))
        {
            Directory.Delete(assetPath, true);
        }
        Directory.CreateDirectory(assetPath);
        if (File.Exists(version))
        {
            string   _ver = File.ReadAllText(version);
            string[] vers = _ver.Split('.');
            if (vers.Length > 1)
            {
                if (vers[2] == "9")
                {
                    vers[2] = "0";
                    if (Convert.ToInt32(vers[1]) < 9)
                    {
                        vers[1] = (Convert.ToInt32(vers[1]) + 1).ToString();
                    }
                    else
                    {
                        vers[1] = "0";
                        if (Convert.ToInt32(vers[0]) < 9)
                        {
                            vers[0] = (Convert.ToInt32(vers[0]) + 1).ToString();
                        }
                    }
                }
                else
                {
                    vers[2] = (Convert.ToInt32(vers[2]) + 1).ToString();
                }
                zipContent = string.Join(".", vers);
                zipPath    = Path.Combine(exportPath, zipContent + ".zip");
                File.WriteAllText(version, zipContent);
            }
            else
            {
                Debug.LogError("版本号格式错误");
            }
        }
        else
        {
            zipContent = "1.0.0";
            File.WriteAllText(version, zipContent);
            zipPath = Path.Combine(exportPath, zipContent + ".zip");
        }
        return(assetPath);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 向版本列表写入数据
    /// </summary>
    /// <param name="zipConent">版本号</param>
    /// <param name="zipSize">资源大小</param>
    private static void WriteVersionListToLocal(string zipConent, long zipSize)
    {
        string exportPath      = PathHelp.GetExportPath();
        string versionListPath = Path.Combine(exportPath, "versionList.txt");
        string vv = string.Empty;

        if (File.Exists(versionListPath))
        {
            vv = File.ReadAllText(versionListPath);
        }
        StringBuilder str = new StringBuilder(vv);

        str.AppendLine();
        str.Append(zipConent);
        str.Append("-");
        str.Append(zipSize);
        File.WriteAllText(versionListPath, str.ToString());
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 启动服务器
    /// </summary>
    private static void StartUpExe(string zipContent)
    {
        System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName("HttpServer");
        if (ps.Length > 0)
        {
            ps[0].Kill();
        }
        if (!Directory.Exists("D:/Res"))
        {
            Directory.CreateDirectory("D:/Res");
        }
        zipContent += ".zip";
        string version            = Path.Combine(PathHelp.GetExportPath(), "version.txt");
        string versionList        = Path.Combine(PathHelp.GetExportPath(), "versionList.txt");
        string zip                = Path.Combine(PathHelp.GetExportPath(), zipContent);
        string server_version     = @"D:\Res\version.txt";
        string server_versionList = @"D:\Res\versionList.txt";
        string server_zip         = @"D:\Res\" + zipContent;

        if (File.Exists(server_version))
        {
            File.Delete(server_version);
        }
        if (File.Exists(server_versionList))
        {
            File.Delete(server_versionList);
        }
        if (File.Exists(server_zip))
        {
            File.Delete(server_zip);
        }
        File.Copy(version, server_version);
        File.Copy(versionList, server_versionList);
        File.Copy(zip, server_zip);
        Debug.Log("启动服务器啦");
        System.Diagnostics.Process.Start(@"E:\XueXi\c#搭建http服务器\HttpServer-master\HttpServer-master\HTTPServer\HTTPServer\bin\Debug\HttpServer.exe");
    }