Hi
Getting above error on this line - byte[] bytes5 = client.DownloadData(s);
C#
dynamic json = JsonConvert.DeserializeObject(response.Content);
string pdf = json.data;
string s = pdf;
int idx = s.LastIndexOf('/');
string fileName = s.Substring(idx + 1);
using (var client5 = new System.Net.WebClient())
{
byte[] bytes5 = client.DownloadData(s);
File.WriteAllBytes(Server.MapPath("~/App_Data/") + fileName, bytes5);
}Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Jan 13, 2023, 10:35 AM EST
test this
dynamic json = JsonConvert.DeserializeObject(response.Content); string pdf = json.data; string s = pdf; int idx = s.LastIndexOf('/'); string fileName = s.Substring(idx + 1); using (var client5 = new System.Net.WebClient()) { byte[] bytes5 = client5.DownloadData(s); File.WriteAllBytes(Server.MapPath("~/App_Data/") + fileName, bytes5); }Ramco RamcoRank #462 · 5.4K reputationPosted Jan 13, 2023, 10:55 AM EST
Hi Sachin
what is the difference between the 2 codes
Thanks
Sachin SinghRank #66 · 26.2K reputationPosted Jan 13, 2023, 10:59 AM EST
client to client5
client5 is an instance of webclient but client is an instance of RestSharp.