The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: BIG Hard drives


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] - (Sorry) - vbscript question



You wanted quick & dirty :-)

On Error Resume Next

Path = "c:\temp"

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(Path)
PathAttrib = f.attributes

if PathAttrib <> "" Then
Msgbox "Path is to a folder"
wscript.quit
end if

Set f = fso.GetFile(Path)
PathAttrib = f.attributes
if PathAttrib <> "" Then
Msgbox "Path is to a file"
wscript.quit
else
msgbox "Path does not exist"
end if

Quoting Paul Gordon <paul_gordon@xxxxxxx>:

> chaps, sorry for the OT, but this is annoying me now...
>
> anyone give me a quick & dirty method to determine via vbscript under WSH
> whether a path points to a file or a directory?
>
> is there a way to determine the type just from a path spec without having to
>
> "Set" an instance of the object in question? - because as far as I can see,
>
> properties like the <object>.attributes can only be used against an
> instantiated object (ie one that has been "Set" to a filesystem object), -
> however, to instantiate it as a filesystem object I have to already know
> whether its a file or a folder! (using the getfile or the getfolder method)
>
> There must be a simple way to do this, but I'm blowed if I can see it at the
>
> moment!
>
> TIA
>
> Paul G. (sitting in the office typing code with gloves on 'cos it's so
> cold!)

Yahoo! Groups Sponsor
ADVERTISEMENT
HGTV Dream Home Giveaway

http://www.automatedhome.co.uk
Post message: ukha_d@xxxxxxx
Subscribe:  ukha_d-subscribe@xxxxxxx
Unsubscribe:  ukha_d-unsubscribe@xxxxxxx
List owner:  ukha_d-owner@xxxxxxx
List of UKHA Groups here - http://groups.yahoo.com/group/UKHA_Grouplists/


Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

Home | Main Index | Thread Index

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.