Is there a way to get a filetype extension from a MIME type (which includes charset as well) without writing long lists of file extensions and mime types?
Also a minor issue; how do I breakstrings separated by a character? For example "text/html; charset=ISO-9859-1" I want to return both "text/html" and "charset=ISO-9859-1" as separate strings.
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { var request = System.Net.HttpWebRequest.Create(((WebTab)ActiveMdiChild).geturl()) as System.Net.HttpWebRequest; string contentType = ""; if (request != null) { var response = request.GetResponse() as System.Net.HttpWebResponse; if (response != null) contentType = response.ContentType; } //I can only retrieve html pages at the moment if (contentType.Contains("text/html")) { System.IO.File.WriteAllText(saveFileDialog1.FileName, ((WebTab)ActiveMdiChild).getsource(),Encoding.Unicode); } }
Ivan