有没有办法在不创建文件的情况下设置长URL字符串?

时间:2015-12-18 19:58:17

标签: c# asp.net devexpress

我在SQL Server表中有想要在Dev Express ASPxImageZoom控件中显示的图像。

此控件具有string类型的ImageUrl属性。

我不想在我的文件服务器上创建大量临时文件。有没有办法在不创建临时文件的情况下设置ImageUrl?

我正在编写一个属性编辑器,用于Dev Express XAF应用程序。 它包含代码

protected override void ReadViewModeValueCore()
        {
            var zoom = (ASPxImageZoom)ZoomControl;  // where ZoomControl is a WebControl
            var bytes = (byte[])PropertyValue;
            if (bytes.Length <= 0)
            {
                return;
            }
            var base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
            zoom.ImageUrl = "data:image/png;base64," + base64String; // fails if length is too long.
        }

如果我的图像很大,我会收到错误。

The specified path, file name, or both are too long. The fully qualified file     name must be less than 260 characters, and the directory name must be less than 248 characters

为控件设置图像的唯一方法是设置ImageUrl,这是一个字符串。

1 个答案:

答案 0 :(得分:0)

问题已在this question

中解决
    string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
    ASPxImageZoom1.ImageUrl = "data:image/png;base64," + base64String;