If fldr
doesn't include the drive letter, FolderExists
looks for this folder in the current wording directory. But your code then creates this folder in C:\
. Most likely, the error occurs because there's no folder with this name in the current working directory, but it exists in C:\
.
Your code should probably be either
function CreateFolder(fldr)
{
if (! fso.FolderExists(fldr))
fso.CreateFolder(fldr);
}
or
function CreateFolder(fldr)
{
var path = fso.BuildPath("C:", fldr);
if (! fso.FolderExists(path))
fso.CreateFolder(path);
}