• Welcome to Jose's Read Only Forum 2023.
 

IFolder.Type Property

Started by José Roca, July 14, 2008, 12:27:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code illustrates the use of the Type property to return a folder type. In this example, try providing the path of the Recycle Bin or other unique folder to the procedure.

JScript


function ShowFileType(filespec)
{
   var fso, f, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   if (fso.FolderExists(filespec))
      f = fso.GetFolder(filespec);
   else if (fso.FileExists(filespec))
      f = fso.GetFile(filespec);
   else
      s = "File or Folder does not exist.";
   s = f.Name + " is a " + f.Type;
   return(s);
}


VBScript


Function ShowFolderType(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(filespec)
   s = UCase(f.Name) & " is a " & f.Type
   ShowFolderType = s
End Function


PowerBASIC


FUNCTION ShowFolderType (BYVAL filespec AS STRING) AS STRING

   LOCAL fso AS IFileSystem
   LOCAL f AS IFile
   LOCAL s AS STRING
   
   fso = NEWCOM "Scripting.FileSystemObject"
   f = fso.GetFolder(UCODE$(filespec))
   s = ACODE$(f.Name) & " is a " & ACODE$(f.Type)
   FUNCTION = s

END FUNCTION