Warm tip: This article is reproduced from serverfault.com, please click

Will path.getrandomfilename generate a unique filename every time?

发布于 2014-02-10 18:05:05

Will Path.GetRandomFileName generate a unique filename every single time? Also, what about Path.GetTempFileName - will that generate a unique name?

Questioner
SandhraPrakash
Viewed
0
Sibster 2014-02-11 02:17:41

The short answer is yes in both cases.
In reality get it will generate 11 random chars that means there are (26 +10)^11 possible names (1.316217e+17) so chances of creating the same name twice are none existand for all practical purposes.

For more information I suggest you read this

and the relevant MSDN pages