Hi,
WebClient is giving exception. It is not able to get the data in ResultInCSV.
- try
- {
- string ServiceURL = $"http://finance.yahoo.com/d/quotes.csv?s={symbol}&f=sl1d1nd";
- string ResultInCSV;
- using (WebClient client = new WebClient())
- {
- ResultInCSV = await client.DownloadStringTaskAsync(ServiceURL).ConfigureAwait(false);
- }
- var FirstLine = ResultInCSV.Split('\n')[0];
- var Price = FirstLine.Split(',')[1];
- if (Price != null && Price.Length >= 0)
- {
- double result;
- if (double.TryParse(Price, out result))
- {
- return result;
- }
- }
- return null;
- }
- catch (WebException ex)
- {
- throw ex.InnerException;
- }
- }
Please help to get the data.
Thanks,