Skip to content

Instantly share code, notes, and snippets.

@5thWall
Created December 13, 2013 17:51
Show Gist options
  • Save 5thWall/9c5e8450c2e1b6307d6b to your computer and use it in GitHub Desktop.
Save 5thWall/9c5e8450c2e1b6307d6b to your computer and use it in GitHub Desktop.
// LINQ all the things
bool FilesValid(HttpFileCollection files, IEnumerable<String> allowedExtensions)
{
return files.AllKeys.Select(s => files[s])
.Any(fi => !AllowedExtensions.Any(s => fi.FileName.EndsWith(s)));
}
// LINQ some of the things
bool FilesValid(HttpFileCollection files, IEnumerable<String> allowedExtensions)
{
foreach (HttpPostedFile file in files.AllKeys.Select(s => files[s]))
{
if (!AllowedExtensions.Any(s => file.FileName.EndsWith(s)))
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment