Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
9
Reply
WebClient is giving exception
Rp Singh
Apr 26 2017 12:38 AM
274
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,
Upload Source Code
Select only zip and rar file.
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#