Skip to content

Instantly share code, notes, and snippets.

@bronumski
Created March 15, 2018 16:16
Show Gist options
  • Select an option

  • Save bronumski/b9fe9bb2454873ae47d3523e90c04c8c to your computer and use it in GitHub Desktop.

Select an option

Save bronumski/b9fe9bb2454873ae47d3523e90c04c8c to your computer and use it in GitHub Desktop.
Remove invalid chars from a file name using linq
public static string CleanFileName(string fileName)
{
return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment