public Boolean IsFileNameValid(String sFileName)
{
foreach(char c in System.IO.Path.InvalidPathChars)
{
if(sFileName.IndexOf(c) > 0)
return false;
}
return true;
}
Public Function IsFileNameValid(ByVal sFileName As String) As Boolean
For Each c As Char In System.IO.Path.InvalidPathChars
If sFileName.IndexOf(c) > 0 Then
Return False
End If
Next
Return True
End Function
I think the code should be (!= -1) because IndexOf() returns -1 if its not in the array (0 is a valid position).