Nobody
Nobody

Reputation: 4841

Exception for when multiple files not found?

Is there an exception that I can use for when there are one or more files not found?

I'm doing this: filePaths.Where(file => !file.Exists); and I need to throw some kind of FilesNotFound exception. Do I need to inherit from Exception and make my own exception class?

I'm using C# .NET 4.

Upvotes: 2

Views: 118

Answers (2)

Iain Ward
Iain Ward

Reputation: 9936

There is already a FileNotFoundException in .NET that you can use if you didn't want to write your own. It only relates to one file though, but you could always inherit it and write a FilesNotFoundException to cater for more than one file

Upvotes: 1

Steve Danner
Steve Danner

Reputation: 22158

It sounds like you should should inherit from System.IO.IOException and expose a Files property on it.

Upvotes: 2

Related Questions