Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
9
Answers
WebClient is giving exception
Rp Singh
7y
296
1
Reply
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,
Post
Reset
Cancel
Answers (
9
)
Next Recommended Forum
convert a jpg/png/txt or any file format to pdf using mvc5
how to download mysqldatabase table to excel format using c#