System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated C# (CSharp) Method

EnsureTempNameCreated() private method

private EnsureTempNameCreated ( ) : void
return void
        private void EnsureTempNameCreated()
        {
            if (_basePath == null)
            {
                string tempFileName = null;
                bool uniqueFile = false;
                int retryCount = 5000;
                do
                {
                    _basePath = Path.Combine(
                        string.IsNullOrEmpty(TempDir) ? Path.GetTempPath() : TempDir,
                        Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
                    tempFileName = _basePath + ".tmp";

                    try
                    {
                        new FileStream(tempFileName, FileMode.CreateNew, FileAccess.Write).Dispose();
                        uniqueFile = true;
                    }
                    catch (IOException ex)
                    {
                        retryCount--;
                        if (retryCount == 0 || ex is DirectoryNotFoundException)
                        {
                            throw;
                        }
                        uniqueFile = false;
                    }
                } while (!uniqueFile);
                _files.Add(tempFileName, KeepFiles);
            }
        }