Пример #1
0
        /// <summary>
        ///     保存资源文件
        /// </summary>
        /// <param name="_data"></param>
        /// <param name="_bytes"></param>
        /// <returns></returns>
        private Boolean saveResourceFile(ResInfo _data, Byte[] _bytes)
        {
            try
            {
                String savePath = _data.SavePath;
                FileHelper.CreateDirectoryByFilePath(savePath);
                //Log.Debug( eLogType.Resources, "保存文件路径: {0}", _data.SavePath );
                FileStream fs = File.Create(savePath);
                fs.Write(_bytes, 0, _bytes.Length);
                fs.Flush();
                fs.Close();
#if UNITY_IPHONE
                iPhone.SetNoBackupFlag(savePath);
#endif
                //下载成功,记录文件位置
                ResInfo newRes = _data.Clone();
                newRes.Location = AssetLocation.PersistentPath;
                mLocalConfig.AddOrUpdateResInfo(newRes);
                mLocalConfig.Save();
                Log.Debug(eLogType.Resources, "成功下载并保存Asset: {0} update list 剩余: {1}", savePath, mUpdateList.Count);
            }
            catch (Exception ex)
            {
                Log.Error(eLogType.Resources, "下载文件保存失败: {0}\n 错误信息: {1}", _data.Name, ex.Message);
                return(false);
            }
            return(true);
        }