Hi everyone,
I'm confused with the code block below because why it downloads the contents of the webpage rather the file itself. I create dummy file with some texts in it then I download it, but when I open the download file, I don't see any text that I wrote but it has weird web language tags.
private bool DownloadCSVfile()
{
bool downloadOk = false;
WebClient client = null;
try
{
client = new WebClient();
client.Credentials = CredentialCache.DefaultCredentials;
client.DownloadFile(myURL, CSVfile);
if (File.Exists(CSVfile))
downloadOk = true;
else
downloadOk = false;
}
catch (Exception error)
{
downloadOk = false;
string err = error.Message;
}
//release resource
if (client != null)
{
client.Dispose();
client = null;
}
//
if (downloadOk == true)
{
return true;
}
else
{
return false;
}
}