How to check if System.Net.WebClient.DownloadData is downloading a binary file?

前端 未结 7 696
太阳男子
太阳男子 2020-11-29 00:24

I am trying to use WebClient to download a file from web using a WinForms application. However, I really only want to download HTML file. Any other type I will

7条回答
  •  遥遥无期
    2020-11-29 01:02

    WebResponse is an abstract class and the ContentType property is defined in inheriting classes. For instance in the HttpWebRequest object this method is overloaded to provide the content-type header. I'm not sure what instance of WebResponse the WebClient is using. If you ONLY want HTML files, your best of using the HttpWebRequest object directly.

提交回复
热议问题