0

我正在使用 rad 控件(图表和 gridview)来开发应用程序,我需要将控件(每个)导出到图像中。我已经尝试将每个控件转换为字节格式并发送到 web 服务并将它们转换为图像,但有时将字节数据发送到服务会引发错误。是否有任何其他方式将每个控件转换为图像。我尝试了另一种方式。

    Stream fileStream = File.OpenRead(@"\\HARAVEER-PC\TempImages\FlashPivot.png");

        //PART 2 - use the stream to write the file output.
        productChart.ExportToImage(fileStream, new Telerik.Windows.Media.Imaging.PngBitmapEncoder());
        fileStream.Close(); 

它给我一个错误,例如无法访问文件夹 TempImages。我已向所有人授予共享权限,但它无法访问该文件夹。

任何解决方案都非常感谢。

4

1 回答 1

0
 private BitmapImage CreateChartImages()
    {
        Guid photoID = System.Guid.NewGuid();
        string photolocation = @"D:\Temp\" + photoID.ToString() + ".jpg";  


        BitmapImage bi = new BitmapImage(new Uri(photolocation, UriKind.Absolute));

        using (MemoryStream ms = new MemoryStream())
        {
            radChart.ExportToImage(ms, new PngBitmapEncoder());
            bi.SetSource(ms);
        }
        return bi;
    }
于 2013-02-26T20:05:15.960 回答