private void DownLoadPackage(IActionName actionName, string WorkingDirectory, string lockFile, string readyFile) { try { Directory.CreateDirectory(Path.GetDirectoryName(lockFile)); using (new FileStream(lockFile, FileMode.CreateNew)) { }; var packFiles = packageProviderService.GetAllPackageFiles(actionName.Provider, actionName.Pack, actionName.Version); var downLoadInfos = packFiles.Select(p => new DownloadInfo { FileSize = p.FileSize, FileHash = p.FileHash, FileUrl = p.FileUrl, LocalFilePath = Path.Combine(WorkingDirectory, p.Path) }).ToArray(); downloadService.DownLoadFiles(downLoadInfos).Wait(); File.WriteAllText(readyFile, "download ready."); } finally { //remove lockFile File.Delete(lockFile); } }