title: how to check if the source path for an bitmapimage is valid in c# mvvm
body: <p>I am trying to get images run-time and based on the ImageFilePathName search for the image. But there are chances that the image doesn't exists but still the source path is created with an Empty Image. Please can anyone suggest how to make a check if the source has the valid file or image in it.? Thanks       </p>
  
  <pre><code>public object Convert(object value, Type targetType, object parameter, string culture)
      {
          StorageFolder installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
          string installFolderPath = installFolder.Path;
          const string LOGO_KIND_SMALL = "Small";
  
          ImageSource source;
          string logoImageFilePathName;
  
                try
          {
              int logoId = Int32.Parse((string)value);
              logoImageFilePathName = string.Format("{0}\\{1}\\Logos\\Chan\\{2}\\{3:0000}.png", installFolderPath, "Assets", LOGO_KIND_SMALL, logoId);
  
              try
              {
                  source = new BitmapImage(new Uri(logoImageFilePathName));
  
                  return source; 
              }
              catch(Exception ex)
              {
                  Logger.LogError(ex.Message);
              }
  
  
          }
          catch (Exception ex)
          {
              Logger.LogError(ex.Message);
          }
  
          logoImageFilePathName = string.Format("{0}\\{1}\\Logos\\Channels\\{2}\\{3}.png", installFolderPath, "Assets", LOGO_KIND_SMALL, "0000");
          source = new BitmapImage(new Uri(logoImageFilePathName));
          return source;
  
  
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, string culture)
      {
          throw new NotSupportedException();
      }
  </code></pre>