src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     This function checks that this is a valid file name. This checks for:
//     1. This file name is not a reserved name, such as 'CON' or 'LPT'
//     2. This file name does not contain any invalid file name characters
// </summary>
This function checks that this is a valid file name. This checks for:
1. This file name is not a reserved name, such as 'CON' or 'LPT'
2. This file name does not contain any invalid file name characters
This function checks that this is a valid file name . This checks for : 1 . This file name is not a reserved name such as ' CON ' or ' LPT ' 2 . This file name does not contain any invalid file name characters
internal static bool IsValidFileName(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return false;
            }
            var filenameWithNoExtension = Path.GetFileNameWithoutExtension(fileName);
            const string reservedNamesRegex = "^((nul|con|aux|prn)(.)?$)|^((com|lpt)[0-9])$";
            var reservedNameMatches = Regex.Matches(
                filenameWithNoExtension, reservedNamesRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
            if (reservedNameMatches.Count != 0)
            {
                return false;
            }
            var invalidPathChars = new[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' };
            if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) != -1
                || fileName.IndexOfAny(invalidPathChars) != -1)
            {
                return false;
            }
            return true;
        }
internal static bool IsValidFileName ( string fileName ) { if ( string . IsNullOrEmpty ( fileName ) ) { return false ; } var filenameWithNoExtension = Path . GetFileNameWithoutExtension ( fileName ) ; const string reservedNamesRegex = " " ; var reservedNameMatches = Regex . Matches ( filenameWithNoExtension , reservedNamesRegex , RegexOptions . CultureInvariant | RegexOptions . IgnoreCase ) ; if ( reservedNameMatches . Count != 0 ) { return false ; } var invalidPathChars = new [ ] { ' \\ ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' } ; if ( fileName . IndexOfAny ( Path . GetInvalidFileNameChars ( ) ) != - 1 || fileName . IndexOfAny ( invalidPathChars ) != - 1 ) { return false ; } return true ; }
This function checks that this is a valid file name.
This function checks that this is a valid file name .
// check that filename w/o extension is not a system reserved name, such as 'CON' // check InvalidFileNameChars and any of: '\', '/', ':', '*', '?', '"', '<', '>', '|'
fileName
string