private async Task <FileListItem[]> _checkBackgroundImages() { List <FileListItem> lfliRet = new List <FileListItem>(); string sFileListURL = ConfigManager.Config.BackgroundImagesSource; string sBaseURL = NetworkUtils.GetBaseURI(sFileListURL); string[] saFileList = await _getBackgroundImagesFileList(sFileListURL); if (saFileList.Length > 0) { foreach (string sFile in saFileList) { FileListItem fliItem = new FileListItem(); if (string.IsNullOrWhiteSpace(sFile)) { continue; } string[] sa = sFile.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (null == sa || sa.Length < 2) { continue; } fliItem.RemoteFileName = sBaseURL + sa[0]; fliItem.RemoteHash = sa[1]; fliItem.LocalFileName = Path.Combine(Constants.ApplicationDataDir, Constants.FILESYSTEM_BACKGROUNDIMAGES, Path.GetFileName(fliItem.RemoteFileName)); fliItem.LocalHash = _getFileHash(fliItem.LocalFileName); lfliRet.Add(fliItem); } } return(lfliRet.ToArray()); }
private async Task _downloadBackgroundImages(FileListItem[] files) { List<Task> ltDownloadList = new List<Task>(); foreach (var oneFile in files) { Console.WriteLine(oneFile); ltDownloadList.Add(_saveFileToDisk(oneFile.RemoteFileName, oneFile.LocalFileName)); } await Task.WhenAll(ltDownloadList); }
private async Task<FileListItem[]> _checkBackgroundImages() { List<FileListItem> lfliRet = new List<FileListItem>(); string sFileListURL = ConfigManager.Config.BackgroundImagesSource; string sBaseURL = NetworkUtils.GetBaseURI(sFileListURL); string[] saFileList = await _getBackgroundImagesFileList(sFileListURL); if (saFileList.Length > 0) { foreach (string sFile in saFileList) { FileListItem fliItem = new FileListItem(); if (string.IsNullOrWhiteSpace(sFile)) { continue; } string[] sa = sFile.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (null == sa || sa.Length < 2) { continue; } fliItem.RemoteFileName = sBaseURL + sa[0]; fliItem.RemoteHash = sa[1]; fliItem.LocalFileName = Path.Combine(Constants.ApplicationDataDir, Constants.FILESYSTEM_BACKGROUNDIMAGES, Path.GetFileName(fliItem.RemoteFileName)); fliItem.LocalHash = _getFileHash(fliItem.LocalFileName); lfliRet.Add(fliItem); } } return lfliRet.ToArray(); }