C#根据byte前两位获取图片扩展名

C#根据byte前两位获取图片扩展名

        /// <summary>
        /// 根据byte前两位获取图片扩展名
        /// </summary>
        /// <param name="bytes01"></param>
        /// <returns></returns>
        public static string GetImageExtensionName(string bytes01)
        {
            string temp = ".jpg";
            switch (bytes01)
            {

                case "255216":
                    temp = ".jpg";
                    break;
                case "7173":
                    temp = ".gif";
                    break;
                case "13780":
                    temp = ".png";
                    break;
                case "6677":
                    temp = ".bmp";
                    break;
                case "4949":
                    temp = ".tiff";
                    break;
                default:
                    temp = ".jpg";
                    break;
            }
            return temp;
        }

  

posted @ 2018-10-18 16:26  小何同學  阅读(946)  评论(0编辑  收藏  举报