Illegal characters in path error

Greetings Experts,
I keep getting the "Illegal characters in path" error, and it seems to come from the System.IO.FileInfo constructor, from System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str).

The characters which trigger this error are special french characters like é, è, à, etc... So my question is:
Is there a way to either allow these characters, or remove them from the filename with some kind of parsing method.

I tried making this method:

        Public Shared Function HasIllegalCharacters(ByVal path As String) As Boolean
            Return (path.IndexOfAny(System.IO.Path.InvalidPathChars) >= 0)
        End Function

But the System.IO.Path.InvalidPathChars doesn't contain these special characters. What should I try next?
Who is Participating?
Jens FiedererTest Developer/ValidatorCommented:
VS2005 considers InvalidPathChars obsolete and prefers the new GetInvalidPathChars method...but there is no guarantee that this is exhaustive ("not guaranteed to contain the complete set of characters that are invalid").

Have you considered doing the opposite?  Just using a set of known LEGAL characters and failing if one of the characters is not in THAT?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.