Saturday, August 10, 2013

Check File name is Valid or Not in C#

Below code snippet will be helpful for checking whether the Input file name contains any Invalid characters which a File name should not contain.
 
public bool IsValidFilename(string testName)
        {
            return testName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) == -1;
        }

Related Posts Plugin for WordPress, Blogger...