Generating Random File Name - Codoid
Select Page
Codoid Blog

Generating Random File Name

Irrespective of the business that your client is in, marketing is an integral part of their operations. In fact, in this day and age of social.

Sometimes we may need to generate a random file name. In VBScript we can use Scriptlet.TypeLib to generate GUID for random data, but length of the GUID is too long.

If we need a shorter random file name, it can be generated using GetRandomFileName method.

Code

Dim oPath,strFileName

'Creating instance of System.IO.Path class which contains GetRandomFileName method
Set oPath=DotNetFactory.CreateInstance("System.IO.Path")

'Assigning random filename in a variable using GetRandomFileName method
strFileName=oPath.GetRandomFileName

Msgbox strFileName

Set oPath=Nothing
  

Although there are several ways to generate random file name, this technique can be used where we require a shorter random data to be used as file name.

Written By

Submit a Comment

Your email address will not be published. Required fields are marked *


Sometimes we may need to generate a random file name. In VBScript we can use Scriptlet.TypeLib to generate GUID for random data, but length of the GUID is too long.

If we need a shorter random file name, it can be generated using GetRandomFileName method.

Code

Dim oPath,strFileName

'Creating instance of System.IO.Path class which contains GetRandomFileName method
Set oPath=DotNetFactory.CreateInstance("System.IO.Path")

'Assigning random filename in a variable using GetRandomFileName method
strFileName=oPath.GetRandomFileName

Msgbox strFileName

Set oPath=Nothing
  

Although there are several ways to generate random file name, this technique can be used where we require a shorter random data to be used as file name.