In C#, is it possible to detect if the web address of a file is an image, or a video? Is there such a header value for this?
I have the following code that gets the filesize of a web file:
System.Net.WebRequest req = System.Net.HttpWebRequest.Create("http://test.png");
req.Method = "HEAD";
using (System.Net.WebResponse resp = req.GetResponse())
{
int ContentLength;
if(int.TryParse(resp.Headers.Get("Content-Length"), out ContentLength))
{
//Do something useful with ContentLength here
}
}
Can this code be modified to see if a file is an image or a video?
Thanks in advance
What you're looking for is the "Content-Type" header