Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4339484
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:13:21+00:00 2026-05-21T11:13:21+00:00

With all the smarts of actually loading images being done by the .net framework,

  • 0

With all the smarts of actually loading images being done by the .net framework, seems like I shouldn’t have to repeat it all in my code by checking for magic numbers, or using a hack like this:

Private Function IsImage(FileName as String) As Boolean
    Try
        Using img As New Bitmap(FileName)
        End Using
    Catch ex as System.ArgumentException
        Return False
    End Try
    Return True
End Function

Am I missing something obvious, like System.Drawing.IsImage(stream)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:13:22+00:00Added an answer on May 21, 2026 at 11:13 am

    You will need to open up the file and read the relevant headers for the file types you want to support, as mentioned here:

    determine if file is an image

    I don’t think there is anything already in the .NET framework that can do this for you, other than loading it into an image and querying the image format:

    Find image format using Bitmap object in C#

    An alternative theory (no actual facts to back this one up): perhaps the file in Windows holds meta-data that flags it as an image – in the same manner than the properties dialog seems to show artist information for audio files. This could be a cute way to avoid opening the file.

    Edit by FastAl Jun 2020. More useful links:

    Using .NET, how can you find the mime type of a file based on the file signature not the extension

    Not what I asked for, but here are the magic #s:

    https://en.wikipedia.org/wiki/List_of_file_signatures

    https://www.garykessler.net/library/file_sigs.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code which actually does all the GUI work for Domain(right side
Loading the image one time works as done in the following steps (for code
Hi all i have written a code to display a message box if invalid
Okay, I actually don't have code as of yet because i'm just picking out
We have for all our tests a method which starts a Jetty Server to
I'm looking at files that all have a different version number that starts at
The script I have written outputs all lines from the file 2 that starts
All, If I run a query like the following: $qry = Select wrong_column from
I have an application consisting of mixed C and x86 assembly code. For complex
I have some fairly straightforward F# async code to download a hundred random articles

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.