private static string GetTempIntermediateFileName(string fileName)
{
string tempFileName=fileName+".x"+_rand.Next().ToString();
// Try at most ten times to get a file name that does not exist in the
// directory.
for(int i=0;File.Exists(tempFileName) && i<10;i++)
{
tempFileName+=fileName+".x"+_rand.Next().ToString();
}
if(File.Exists(tempFileName))
throw new FatalException("Could not create a temporary file in the directory.");
return tempFileName;
}