Path.GetRandomFileName Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a random folder name or file name.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)


Public Shared Function GetRandomFileName As String
public static string GetRandomFileName()

Return Value

Type: System..::.String
A random folder name or file name.


The GetRandomFileName method returns a cryptographically strong, random string that can be used as either a folder name or a file name. Unlike GetTempFileName, GetRandomFileName does not create a file. When the security of your file system is paramount, this method should be used instead of GetTempFileName.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0

See Also


Path Class

System.IO Namespace