title: SSRS External Images with Dynamic File Extensions
body: <p>I have a report that needs to show images from a Windows folder on the server, which is working (see <a href="https://stackoverflow.com/questions/45112164/display-images-from-windows-folder-in-ssrs-report/45112208#45112208">here</a> ). Now, I am wondering how to get the report to pull images of differing file types, like jpg &amp; tif. (I am using png by default). Is there a relatively easy way to do this? The image names with file extension are not in the SQL database. </p>
  
  <p>EDIT: I entered this in the Custom Code block, from Daniel's help below.  </p>
  
  <p><code>Public Function GetImage(ByRef Filename As String) As String
      ' Full image path used for testing if it exists
      Dim ImagePath As String
      ImagePath = "\\GVSSERVER1\GVSServerD\Acclamare_Images\" + Filename</code> <code>
    ' Test to see if the file exists as a gif
      Try
          If System.IO.File.Exists(ImagePath + ".png")
              Return "file://" + ImagePath + ".png"
          ElseIf System.IO.File.Exists(ImagePath + ".jpg")
          Else Return "file://" + ImagePath + ".jpg"
          End If
      Catch ex As Exception
          Return "Hit an Error"
      End Try
      Return "Hit the end"
      End Function</code><br>
  When I run the report, it fetches the .jpg extension even though the image file is a png, and there isn't a jpg file for that item. Any idea on how to correct that?<br>
                                                                                                                                                                   EDIT 2: I wasn't having success with the updated custom code, but I could have been missing something, as I'm no expert with custom code. I found this question <a href="https://stackoverflow.com/questions/11740000/check-for-file-exists-or-not-in-sql-server">(see here)</a> which is for a function. I tried it and it works, except for some reason .tif files don't display on the report. I installed Microsoft Picture Manager (from the Sharepoint exe download), but it still doesn't display the .tif files.</p>