static void Main(string[] args) { var baseDiskPath = @"C:\Temp\"; var baseCosmosPath = "https://cosmos15.osdinfra.net/cosmos/dsa.email.segmentation/local/users/MeritDirect/Product/"; foreach (var streamPath in GetStreamsRecurse(baseCosmosPath, new Regex(@"\.txt$"))) //foreach (var streamPath in GetStreamsRecurse(baseCosmosPath, new Regex(@"OneStore_Order_VID_2019.*\.txt$"))) { //var relativeStreamPath = streamPath.Replace(baseCosmosPath, string.Empty); //var fullCosmosPath = Path.Combine(baseCosmosPath, relativeStreamPath); var uri = new Uri(streamPath); var relativeStreamPath = uri.Segments[uri.Segments.Length - 1]; /* * var fullDiskPath = Path.Combine(baseDiskPath, relativeStreamPath); * * var directory = Path.GetDirectoryName(fullDiskPath); * if (!Directory.Exists(directory)) * { * Directory.CreateDirectory(directory); * } */ VC.Download(streamPath, baseDiskPath + relativeStreamPath, true, DownloadMode.OverWrite); } }
public static void DownloadStream(string cosmosStream, string localFile) { for (int retries = 0; retries < CosmosRetryTimes; retries++) { try { if (VC.StreamExists(cosmosStream)) { VC.Download(cosmosStream, localFile, false, true); } break; } catch (Exception) { if (retries >= CosmosRetryTimes - 1) { throw; } System.Threading.Thread.Sleep(1000 * 60); } } }
public static void DownloadKlondikeFile(string cosmosPath, string downloadPath, string updateDate) { var baseDiskPath = downloadPath; var baseCosmosPath = cosmosPath; baseCosmosPath = baseCosmosPath + updateDate; foreach (var streamPath in GetStreamsRecurse(baseCosmosPath, new Regex(@"\.csv$"))) { var relativeStreamPath = streamPath.Replace(baseCosmosPath, string.Empty); var fullCosmosPath = Path.Combine(baseCosmosPath, relativeStreamPath); //var fullDiskPath = Path.Combine(baseDiskPath, relativeStreamPath); var fullDiskPath = baseDiskPath + relativeStreamPath.Replace("/", ""); /* * var directory = Path.GetDirectoryName(fullDiskPath); * if (!Directory.Exists(directory)) * { * Directory.CreateDirectory(directory); * } */ //VC.Download(fullCosmosPath, fullDiskPath, true, DownloadMode.OverWrite); VC.Download(streamPath, fullDiskPath, true, DownloadMode.OverWrite); } }