BB.UI.Web.MVC.Controllers.Utils.FileHelper.NextAvailableFilename C# (CSharp) Method

NextAvailableFilename() public static method

public static NextAvailableFilename ( string path ) : string
path string
return string
            public static string NextAvailableFilename(string path)
            {
                // Short-cut if already available
                if (!File.Exists(path))
                    return path;

                // If path has extension then insert the number pattern just before the extension and return next filename
                if (Path.HasExtension(path))
                    return GetNextFilename(path.Insert(path.LastIndexOf(Path.GetExtension(path)), numberPattern));

                // Otherwise just append the pattern to the path and return next filename
                return GetNextFilename(path + numberPattern);
            }