private static void CreateCacheFolder() { var cacheDir = MiscHelpers.GetCachePath(); Logging.LogTrace("Checking for cache dir at {0}", cacheDir); Directory.CreateDirectory(cacheDir); }
public string DownloadFile() { var uri = new Uri(Url); var destination = string.Format("{0}\\{1}", MiscHelpers.GetCachePath(), uri.Segments.Last()); var fileInfo = new FileInfo(destination); if (!fileInfo.Exists) { using (var wc = new WebClient()) { wc.Headers.Add("User-Agent", "Rhetos CLI"); wc.DownloadFileCompleted += HandleDownloadComplete; var syncObject = new Object(); lock (syncObject) { Logging.LogInfo("Downloading file {0} {1}%", Url, 0); wc.DownloadFileAsync(uri, destination, syncObject); //Wait for download to complete (or fail)... Monitor.Wait(syncObject); } } } else { Logging.LogWarn("File exists download skipped..."); } return(destination); }