Tony said:
Hi!
I just wonder if anyone has any good experience when it's good to use
GetRandomFileName instead of
GetTempFileName when using the Path class.
Seems to me the docs are pretty clear on the topic: use the former when
you require the security of a truly "cryptographically strong" random
filename.
More specifically, GetTempFileName() uses a fairly simple and
predictable algorithm for generating filenames. That could be an avenue
of attack for some malicious code that is trying to find a specific
temporary file generated, perhaps by some other process, etc.
Not that using GetRandomFileName() will in and of itself provide
security. But it's one piece of a larger security puzzle.
In general, if you don't know why you should use GetRandomFileName(),
then you probably don't need to.
Pete