Does anyone know why the code below throws System.ArgumentException?
using (var tfc = new TempFileCollection())
{
var fn = tfc.AddExtension("tmp");
Console.WriteLine(fn);
}
Here is exact exception:
System.ArgumentException: The file name 'C:\Users\pczapla\AppData\Local\Temp\iqulrqva.tmp' was already in the collection.
Parameter name: fileName.
A little Reflector action reveals the following interesting snippet in
TempFileCollection:This is in
TempFileCollection.EnsureTempNameCreated, which is called byTempFileCollection.BasePath, which is called byTempFileCollection.AddExtension. I guess the placeholder uses “.tmp” so you cannot.