How to resolve the algorithm Empty directory step by step in the VBScript programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Empty directory step by step in the VBScript programming language
Table of Contents
Problem Statement
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other entries.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Empty directory step by step in the VBScript programming language
Source code in the vbscript programming language
Function IsDirEmpty(path)
IsDirEmpty = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(path)
If objFolder.Files.Count = 0 And objFolder.SubFolders.Count = 0 Then
IsDirEmpty = True
End If
End Function
'Test
WScript.StdOut.WriteLine IsDirEmpty("C:\Temp")
WScript.StdOut.WriteLine IsDirEmpty("C:\Temp\test")
You may also check:How to resolve the algorithm Modular inverse step by step in the Action! programming language
You may also check:How to resolve the algorithm Priority queue step by step in the Logtalk programming language
You may also check:How to resolve the algorithm Function prototype step by step in the Oforth programming language
You may also check:How to resolve the algorithm String length step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Emirp primes step by step in the VBA programming language