zoukankan      html  css  js  c++  java
  • WP7中判断图片是否存在

        string mapPath = station.mapPath;
                Uri imageUri = new Uri("/Subway;component/" + mapPath, UriKind.Relative); // mapPath对应图片BuildAction为Resource;  Subway指的是工程名

        // Uri imageUri = new Uri(mapPath, UriKind.Relative); // mapPath对应图片BuildAction为Content
                System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(imageUri);
                if (sri == null)
                {
                    // 图片不存在

                    BrieflyImage.Source = new BitmapImage(new Uri(StaticStrings.DefaultStationPicturePath, UriKind.RelativeOrAbsolute));
                }
                else
                {

           // 图片存在
                    BitmapImage image = new BitmapImage();
                    image.SetSource(sri.Stream);
                    BrieflyImage.Source = image;
                }

  • 相关阅读:
    python day01
    Mac上安装pexpect
    raid
    SSL证书制作
    linux grep命令详解
    第一轮迭代小组成员分数分配
    M1事后分析报告(Postmortem Report)
    软件发布说明
    测试报告
    week 9 scenario testing
  • 原文地址:https://www.cnblogs.com/crazystars/p/2218346.html
Copyright © 2011-2022 走看看