Is there any way to set a long url string without creating a file?

孤街浪徒 提交于 2019-12-10 23:54:22

问题


I have images in an SQL Server table that I want to display in a Dev Express ASPxImageZoom control.

This control has an ImageUrl property of type string.

I don't want to create lots of temporary files on my file server. Is there any way I can set the ImageUrl without creating a temporary file ?

I am writing a property editor for use in a Dev Express XAF application. It contains the code

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

If I have a large image I get an error.

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

The only way of setting the image for the control is via setting the ImageUrl which is a string.


回答1:


The problem was solved in this question

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


来源:https://stackoverflow.com/questions/34363040/is-there-any-way-to-set-a-long-url-string-without-creating-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!