IndexOfInvalidFileNameChars() public static method

Finds the first character index of any characters that are invalid in a file name. This method (and IndexOfInvalidPathChars) avoid the allocation of the array each time Path.GetInvalidFileNameChars is called.
public static IndexOfInvalidFileNameChars ( string path ) : int
path string Path to check. Can not be null.
return int
        /// <summary>
        /// Attempts to load a StObjMap from an assembly name.
        /// <para>
        /// If a <see cref="SuffixSignature"/> file exists and contains a valid signature, the StObjMap is
        /// loaded from the <see cref="GetAvailableMapInfos(IActivityMonitor?)"/> if it exists.
        /// </para>
        /// </summary>
        /// <param name="assemblyName">The assembly name.</param>
        /// <param name="monitor">Optional monitor to use.</param>
        /// <returns>A <see cref="IStObjMap"/> that provides access to the objects graph.</returns>
        public static IStObjMap?Load(string assemblyName, IActivityMonitor?monitor = null)
        {
            Throw.CheckNotNullOrEmptyArgument(assemblyName);
            Throw.CheckArgument(FileUtil.IndexOfInvalidFileNameChars(assemblyName) < 0);

            if (!assemblyName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) &&
                !assemblyName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
            {
                assemblyName = assemblyName + ".dll";
            }
            string assemblyFullPath = Path.Combine(AppContext.BaseDirectory, assemblyName);
            var    signaturePath    = assemblyFullPath + SuffixSignature;

            if (File.Exists(signaturePath) &&
                SHA1Value.TryParse(File.ReadAllText(signaturePath), out var signature))
            {
                var map = Load(signature, monitor);
                if (map != null)
                {
                    return(map);
                }
            }

            lock ( _alreadyHandled )
            {
                LockedEnsureMonitor(ref monitor);
                using (monitor.OpenInfo($"Loading StObj map from '{assemblyName}'."))
                {
                    try
                    {
                        // LoadFromAssemblyPath caches the assemblies by their path.
                        // No need to do it.
                        var a    = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyFullPath);
                        var info = LockedGetMapInfo(a, ref monitor);
                        if (info == null)
                        {
                            return(null);
                        }
                        return(LockedGetStObjMapFromInfo(info, ref monitor));
                    }
                    catch (Exception ex)
                    {
                        monitor.Error(ex);
                        return(null);
                    }
                }
            }
        }