I am a Jr. Programmer trying to get mp4 videos from an API and save them to a folder on the network. I am using the following code;
public static void saveVideos(HttpContent content, String filename, bool overwrite)
{
string pathName = Path.GetFullPath(filename);
using (FileStream fs = new FileStream(pathName, FileMode.Create, FileAccess.Write, FileShare.None))
{
if (fs.CanWrite)
{
byte[] buffer = Encoding.UTF8.GetBytes(content.ToString());
fs.Write(buffer, 0, buffer.Length);
fs.Flush();
fs.Close();
}
}
}
The code will compile without errors but all videos are written to the folder with a size of 1KB. I can't seem to figure out why I am not getting all of the file.
When I inspect the value of the content I see I am getting data that looks like this:
Headers = {Content-Length: 240634544
Content-Disposition: attachment; filename=Orders.dat
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Can anyone point out my error here?
Thanks