zoukankan      html  css  js  c++  java
  • 从WebResponse获取源文件名、扩展名

            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;
            }

  • 相关阅读:
    安卓模拟器黑屏
    关系型数据库的1NF、2NF、3NF
    flowable数据库详解
    spring事务传播行为详解
    springboot整合activity
    各种java面试题目
    springCloud中增加gateway(超详细)
    mysql实现主从复制
    flowable整合springboot
    window安装linux系统
  • 原文地址:https://www.cnblogs.com/dashi/p/4034752.html
Copyright © 2011-2022 走看看