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

GetUniqueFolderName() static private méthode

if necessary, append a number to make the subfolder name unique within the given folder
static private GetUniqueFolderName ( string parentPath, string name ) : string
parentPath string
name string
Résultat string
        internal static string GetUniqueFolderName(string parentPath, string name)
        {
            int i = 0;
            string suffix = "";
            while (Directory.Exists(Path.Combine(parentPath, name + suffix)))
            {
                ++i;
                suffix = i.ToString(CultureInfo.InvariantCulture);
            }
            return name + suffix;
        }

Usage Example

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

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