Enum.IsDefined will take a string containing the name of an enum value. The only ugliness is that you have to strip the leading period off of File.Extension and it's case sensitive:
Enum.IsDefined(typeof(FileExtension), file.Extension.Substring(1).ToLower())
Edit: Extension method goodness to get close to your desired syntax:
IEnumerable<string> GetNames(this Type t) {
if (!t.IsEnum) throw new ArgumentException();
return Enum.GetNames(t);
}
typeof(FileExtensions).GetNames().Any(e=>e.ToString().Equals(file.Extension));
Personally, though, I'd still rather the IsDefined route:
bool IsDefined(this Type t, string name) {
if (!t.IsEnum) throw new ArgumentException();
return Enum.IsDefined(t, name);
}
typeof(FileExtension).IsDefined(file.Extension);