中文
    达人设计 V
    职业:网页设计
    LV.1 2019-06-09 10:19:34 分享 举报
    内容简介:razor C#把文件转Base64字符串
    razor C#把文件转Base64字符串
    2019-06-09 10:19:34 作者:达人设计 LV.1 职业:网页设计 浏览(3198) 喜欢(0) 评论(0)

    @functions{

        public static string Base64String(string url)

        {

            try{

                var location = Server.MapPath(url);

                System.IO.FileStream file = System.IO.File.OpenRead(location);

                System.IO.BinaryReader Binary = new BinaryReader(file);

                byte[] bytes = Binary.ReadBytes(Convert.ToInt32(file.Length));

                string base64String = Convert.ToBase64String(bytes);

                return base64String;

            }

            catch{

                return "";

            }

        }

    }

    输出

    <video controls="controls" autoplay="autoplay" style="width:1200px;"><source src="data:video/mp4;base64,@razor.Base64String(url)"  type="video/mp4"></video>

    •  最多可以输入200个字符
    双击图片添加 X
    双击图片添加 X
    支付方式 |网页设计 |联系我们 |帮助中心 |网站地图 |app |微信
    技术支持: 达人设计  版权所有:© 达人设计  邮箱:605034058@qq.com  电话:13622397622   备案:粤ICP备13034152号  地址:深圳市南山区西丽社区2506