private string FindOpenSlot(string thumbprint)
{
// We already know that {thumbprint}.pfx is taken, so start with {thumbprint}.1.pfx
// We need space for {thumbprint} (thumbprint.Length)
// And ".0.pfx" (6)
// If MaxSaveAttempts is big enough to use more than one digit, we need that space, too (MaxSaveAttempts / 10)
StringBuilder pathBuilder = new StringBuilder(thumbprint.Length + PfxOrdinalWildcard.Length + (MaxSaveAttempts / 10));
pathBuilder.Append(thumbprint);
pathBuilder.Append('.');
int prefixLength = pathBuilder.Length;
for (int i = 1; i <= MaxSaveAttempts; i++)
{
pathBuilder.Length = prefixLength;
pathBuilder.Append(i);
pathBuilder.Append(PfxExtension);
string builtPath = Path.Combine(_storePath, pathBuilder.ToString());
if (!File.Exists(builtPath))
{
return builtPath;
}
}
throw new CryptographicException(SR.Cryptography_X509_StoreNoFileAvailable);
}