Bloom.Book.BookStorage.SanitizeNameForFileSystem C# (CSharp) Méthode

SanitizeNameForFileSystem() static private méthode

static private SanitizeNameForFileSystem ( string name ) : string
name string
Résultat string
        internal static string SanitizeNameForFileSystem(string name)
        {
            name = RemoveDangerousCharacters(name);
            if (name.Length == 0)
            {
                // The localized default book name could itself have dangerous characters.
                name = RemoveDangerousCharacters(BookStarter.UntitledBookName);
                if (name.Length == 0)
                    name = "Book";	// This should absolutely never be needed, but let's be paranoid.
            }
            const int MAX = 50;	//arbitrary
            if (name.Length > MAX)
                return name.Substring(0, MAX);
            return name;
        }

Usage Example

        private string GetInitialName(string parentCollectionPath)
        {
            var name = BookStorage.SanitizeNameForFileSystem(UntitledBookName);

            return(BookStorage.GetUniqueFolderName(parentCollectionPath, name));
        }