private void GetDriverData() { try { log.Info("Start looking for new driver data"); var driverDataList = ddInfosApiInstance.GetDdInfo(); foreach (var driverData in driverDataList) { if (!File.Exists(driverPath + driverData.XmlRef)) { log.Info("New driver data for " + driverData.XmlRef + " found"); string xmlref = driverData.XmlRef; string format = null; Stream response = ddFileApiInstance.GetDdfileByRef(xmlref, format); FileStream file = new FileStream(driverPath + driverData.XmlRef, FileMode.Create, FileAccess.Write); response.CopyTo(file); file.Close(); log.Info("New driver data for " + driverData.XmlRef + " written"); } } log.Info("End looking for new driver data"); } catch (Exception e) { throw new Exception("Error by getting driver data", e); } }
static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ddInfosApiInstance = new DdInfosApi(); var driverDataList = ddInfosApiInstance.GetDdInfo(); foreach (var driverData in driverDataList) { if (!File.Exists(path + driverData.XmlRef)) { ddFileApiInstance = new DdFileApi(); string xmlref = driverData.XmlRef; string format = null; Stream response2 = ddFileApiInstance.GetDdfileByRef(xmlref, format); FileStream file = new FileStream(path + driverData.XmlRef, FileMode.Create, System.IO.FileAccess.Write); response2.CopyTo(file); } } Console.ReadKey(); }