Microsoft.VsSDK.IntegrationTestLibrary.TestUtils.GetNewFileOrDirectoryNameWithoutCreatingAnything C# (CSharp) Method

GetNewFileOrDirectoryNameWithoutCreatingAnything() private static method

private static GetNewFileOrDirectoryNameWithoutCreatingAnything ( string directory, string baseFileName, string extension ) : string
directory string
baseFileName string
extension string
return string
        private static string GetNewFileOrDirectoryNameWithoutCreatingAnything(string directory, string baseFileName, string extension)
        {
            // - get a file name that we can use
            string fileName;
            int i = 1;

            string fullFileName = null;
            while (true)
            {
                // construct next file name
                fileName = baseFileName + i;
                if (extension != null)
                    fileName += '.' + extension;

                // check if that file exists in the directory
                fullFileName = Path.Combine(directory, fileName);

                if (!File.Exists(fullFileName) && !Directory.Exists(fullFileName))
                    break;
                else
                    i++;
            }

            return fullFileName;
        }