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 466655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:30:08+00:00 2026-05-12T23:30:08+00:00

I am writing an app and I want to load a file based on

  • 0

I am writing an app and I want to load a file based on a path provided by the user. I check the extension of the file and when the extension does not match anything I recognize I want to throw an exception.

I could throw an IOException. But, I figured there could be a more detailed exception derived from that. So I looked at MSDN and found FileLoadException. The name suggests that my error would fit in this category, but…. when I look on MSDN it says: “Represents the error that occurs when a Assembly file is found but cannot be loaded.” and “The exception that is thrown when a managed assembly is found but cannot be loaded.” That is absolutely not what is the case with my error.

So what is the question then? Well, I wonder if the documentation actually means that the exception is meant to be thrown for this purpose only or that they just mean that they throw that exception in that specific case, but do not really specify when others should throw it.

On the IOException page on MSDN it does advice to use FileLoadException where appropriate:

IOException is the base class for exceptions thrown while accessing information using streams, files and directories.

The Base Class Library includes the following types, each of which is a derived class of IOException:

  • DirectoryNotFoundException
  • EndOfStreamException
  • FileNotFoundException
  • FileLoadException
  • PathTooLongException

Where appropriate, use these types instead of IOException.

Summarized: In case of an unknown file extension, should I throw an IOException or a FileLoadException (I do not want to define my own exception).

Thanks in advance.

  • 1 1 Answer
  • 1 View
  • 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-12T23:30:08+00:00Added an answer on May 12, 2026 at 11:30 pm

    You should throw IOException, and never throw FileLoadException which is very specific and “technical” (whereas your exception should be “application oriented”). Try to analyze FileLoadException type with Reflector (in mscorlib), you’ll see that it’s only used for the purpose defined in the msdn. Then imagine one day your code used in a “plugin context”, how will react the host program catching a FileLoadException meaning an assembly failed to load properly …

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

Sidebar

Related Questions

I'm writing a VB.NET app where I want to load an internal text file
I'm writing a 'load' feature for my current iPhone app. Practically what I want
I'm writing an app to view an online web text-based game. I want to
I am writing an app that uses Highcharts, and in one instance I want
I'm writing an app with GWT, which I want to deploy to Google App
I'm writing a JNI application and I want the app to download the correct
I am writing an android app. I want to pass some data across the
I am writing a Ruby on Rails app and I want a method to
I am writing my first comprehensive app using Core Data, and I want to
i am writing a simple folder synchronization app. Therefore i want at the time

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.