To check if a filepath contains Invalid characters you can use the following snippet.
Sample C#
public static bool IsValidFilename(string fileName) { return Path.GetInvalidFileNameChars().All(invalidChar => fileName.Contains(invalidChar) != true); }
Sample VB.NET
Public Shared Function IsValidFilename(fileName As String) As Boolean Return Path.GetInvalidFileNameChars().All(Function(invalidChar) fileName.Contains(invalidChar) <> True) End Function
for more informations see the MSDN Path.GetInvalidFileNameChars Method
RT @CodeSnippetsNET: check if a filepath contains Invalid characters http://t.co/Jr15PFxMTM #csharp