vendredi 30 octobre 2015

What's the use of TempFileCollection.AddExtension if it doesn't return unique names?

I need to create three temporary XML files for debugging purposes. I'm using a TempFileCollection as it fits the bill, but apparently the AddExtension method doesn't actually return unique file names.

According to the MSDN:

This method can be called only once for each file name extension, because it will return the same name if it is called with the same extension.

Apparently I just have to add my own files anyway using the AddFile method. What's the use of this method then? To work around it I'm just using

var filename = Guid.NewGuid().ToString + ".xml"
collection.AddFile(filename, false);

Aucun commentaire:

Enregistrer un commentaire