static string GetFilenameFromResponse(WebResponse wr, string defaultFilename)
{
string desc = wr.Headers["Content-Disposition"];
if (desc != null)
{
string fstr = "filename=";
int pos1 = desc.IndexOf(fstr);
if (pos1 > 0)
{
string fn = desc.Substring(pos1 + fstr.Length);
if (fn != "")
defaultFilename = System.Environment.CurrentDirectory + "\\" + fn;
}
}
return defaultFilename;
}
static string GetExtensionFromResponse(WebResponse wr,string defaultExt)
{
Hashtable htmimes = new Hashtable();
htmimes["image/jpeg"] = ".jpg";
htmimes["image/png"] = ".png";
htmimes["image/tiff"] = ".tif";
htmimes["image/bmp"] = ".bmp";
htmimes["image/gif"] = ".gif";
string ct = wr.ContentType;
if (ct != null)
{
if (htmimes.ContainsKey(ct)) defaultExt = htmimes[ct].ToString();
}
return defaultExt;
}