I must be missing something. I am downloading a file and want to save it as its type. I know this is supposed to end up as jpg, in this case.
When I save the byte array to a file I get the following:
--145ae7dc-e075-478c-8063-eeb765e0e15a
Content-Type: image/jpeg;
Content-Length: 41946
MIME-Version: 1.0
ÿØÿî Adobe d ÿÃ R G B ÿÄ ÿÚ R G B úÿ ×þ¿Úív¡
Code:
WebClient webClient = new WebClient();
webClient.Headers["Accept"] = textBoxMimeType.Text;
var uri = new Uri(url);
using (Stream webStream = webClient.OpenRead(uri))
{
using (FileStream fileStream = new FileStream(outputFile, FileMode.Create))
{
var buffer = new byte[32768];
int bytesRead;
Int64 bytesReadComplete = 0;
Int64 bytesTotal = Convert.ToInt64(webClient.ResponseHeaders["Content-Length"]);
while ((bytesRead = webStream.Read(buffer, 0, buffer.Length)) > 0)
{
bytesReadComplete += bytesRead;
fileStream.Write(buffer, 0, bytesRead);
}
}
}
I use the above because I may have a very large file.
Another file comes across as "application/octet-stream"...
I want be able to download other mime types as well.
How do I get rid of the MIME header and save the binary data?
I have tried MimeKit and it fails to parse the body.
Thx