The following piece of code is used to read a file from server and download it to the client pc:
var webClient = new WebClient();
webClient.OpenReadCompleted += (s, e) =>
{
using (var fs = (Stream) dialog.OpenFile())
{
e.Result.CopyTo(fs);
fs.Flush();
fs.Close();
}
};
webClient.OpenReadAsync(GetFileUri(fileToDownload));
When downloading a .txt file everything is ok. But when I try to download a .dat file I get following exception: System.Reflection.TargetInvocationException with inner exception System.Net.WebException: The remote server returned an error: NotFound.The Uri is relative and doesn't present an issue with the .txt file.
I can't seem to find information if this should be possible or what the issue could be. The error itself also doesn't give me much. Any thoughts?