-
February 23rd, 2011, 07:36 PM
#1
Does code match requirements
1. Prompt user to input path to some folder on system
2. Get a folder object to represent that folder
3. Get a files collection to represent all the files in the folder the user has selected
4. Check number of files in your collection. If its 0 generate message box that folder does not contain files. If it does contain files, generate message box that indicates number of files.
This is what I came up with:
Code:
Option Explicit
Dim fso, folderid, yourfiles, yourfolder
'First, I need a file system object
Set fso = WScript.CreateObject("scripting.filesystemobject")
'Get a drive letter from the user.
folderid = InputBox("Please enter a path to a folder.","Information","C:\")
If fso.FolderExists(folderid) Then
Set yourfolder = fso.GetFolder(folderid)
Set yourfiles = yourfolder.files
MsgBox "Your folder (" & folderid & ") exists."
Else
MsgBox "Your folder (" & folderid & ") does not exist."
End if
If fso.FolderExists(folderid) Then
MsgBox "Your folder (" & folderid & ") contains " & yourfiles.Count & " folders."
Else
MsgBox "Your folder " & folderid & " has NOT been found."
End if
If yourfiles.count = 0 Then
MsgBox "Your folder does not contain any files."
Else
MsgBox "Your folder contains " & yourfiles.Count & " files!"
End if
Last edited by PeejAvery; February 24th, 2011 at 07:49 AM.
Reason: Added code tags
-
February 24th, 2011, 07:50 AM
#2
Re: Does code match requirements
Once again...what is your question? And please start using code tags.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|