i am put some code for file download. Its downloaded successfully but created file get corrupted no content is shown there. Please help me …my code is
client = new RestClient(“https://api.pipedrive.com/v1/files/” + id + “/download?api_token=” + token);
client.Timeout = -1;
client.FollowRedirects = true;
request = new RestRequest(Method.GET);
request.AlwaysMultipartFormData = true;
response = client.Execute(request);
if (response.StatusCode == HttpStatusCode.OK)
{
objfiledetail.Filedata = Encoding.ASCII.GetBytes(response.Content);
objfiledetail.FileType = response.ContentType;
string pdefaultpath = Path.Combine(Directory.GetCurrentDirectory(), "File");
string newPath = Path.Combine(pdefaultpath, objfiledetail.EamilId.ToString());
if (!Directory.Exists(newPath))
{
Directory.CreateDirectory(newPath);
}
string filePath = Path.Combine(newPath, objfiledetail.FileName);
File.WriteAllBytes(filePath, objfiledetail.Filedata);
}
.png is okay but other file format not supported
Thanks in advance…