public static string GetServerGameResPath(DownLoadFileInfo info) { string path = Path.Combine(ServerGameResAndroidPath, ResDirectoryName, info.GameName, info.fileName); path = path.Replace("\\", "/"); return(path); }
private void InitGameResFileInfo() { StreamReader streamReader = new StreamReader(Path.Combine(URLFactory.DownLoadHotFilePath, "AssetList.txt")); string str = null; while (!streamReader.EndOfStream) { str = streamReader.ReadLine(); if (str.Contains("//")) { continue; } if (str.Contains("ApplicationVersion")) { URLFactory.NewAppVersion = str.Split('~')[0]; continue; } else if (str.Contains("ApkUrl")) { URLFactory.NewAppVersion = str.Split('~')[0]; continue; } DownLoadFileInfo info = new DownLoadFileInfo(str); if (info.IsInvalid) { continue; } if (!_gameResfileInfoDict.ContainsKey(info.GameName)) { _gameResfileInfoDict[info.GameName] = new GameResFileInfo(info.GameName); } _gameResfileInfoDict[info.GameName].AddFileInfo(info); } streamReader.Close(); foreach (string gameName in _gameResfileInfoDict.Keys) { GameVersionState state = GetGameResVersionState(gameName); _gameVersionStateDict[gameName] = state; } IsInited = true; }
public void StartDownLoad(DownLoadFileInfo info) { if (IsDownLoading) { return; } Init(); CurDownLoadFileInfo = info; Progress = 0; IsDone = false; IsDownLoading = true; string serverGameResPath = URLFactory.GetServerGameResPath(info); string localSavePath = URLFactory.GetLocalGameResSavePath(info); if (File.Exists(localSavePath)) { File.Delete(localSavePath); } _myWebClient.DownloadFileAsync(new Uri(serverGameResPath), localSavePath); }
public static GameVersionState CheckOnceFileInfo(DownLoadFileInfo info) { int gameServerVersion = info.version; string localTagPath = URLFactory.GetLocalGameTagPath(info); if (File.Exists(localTagPath)) { StreamReader streamReader = new StreamReader(localTagPath); string versionStr = streamReader.ReadToEnd(); streamReader.Close(); int versioni; if (int.TryParse(versionStr, out versioni)) { if (versioni >= gameServerVersion) { return(GameVersionState.NewestVersion); } return(GameVersionState.OldVersion); } } return(GameVersionState.UnLoad); }
public void AddFileInfo(DownLoadFileInfo info) { infoList.Add(info); }
/// <summary> /// 获取本地标记文件全路径 /// </summary> /// <param name="info"></param> /// <returns></returns> public static string GetLocalGameTagPath(DownLoadFileInfo info) { string folderPath = GetLocalGameTagFolder(info.GameName); return(Path.Combine(folderPath, info.fileName + ".txt")); }
/// <summary> /// 获取本地资源文件全路径 /// </summary> /// <param name="info"></param> /// <returns></returns> public static string GetLocalGameResSavePath(DownLoadFileInfo info) { string folderPath = GetLocalGameResSaveFolder(info.GameName); return(Path.Combine(folderPath, info.fileName)); }