Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=180600004

Script, Scripting Language, VBScript elements, Server-Side VBScript FileSystemObject Drives Object

VBScript FSO Drives Collection

Drives Collection is a VBScript Object designed for providing simple file sytem accessing, and folders and files processing.. Twenty-six Methods are provided for the manipulation of the file system objectes. Ane one property is provided for returning of all available drives in the file system for further manipulation.

The returns of Drives Property is a collection of available drive objects, that is the Drives Collection. Additional Count Property, and Item Property are provided for accessing the Properties of Drives Collection directly. Although further properties can be accessed through dot notation, another Object called Drive Object is defined for manipulating these properties of each returned object separately.

  • FileSystemObject Mehtod
    • BuildPath Method
    • CopyFile Method
    • CopyFolder Method
    • CreateFolder Method [≡ Folder object]
    • CreateTextFile Method ≡ TextStream object
    • DeleteFile Method
    • DeleteFolder Method
    • DriveExists Method
    • FileExists Method
    • FolderExists Method
    • GetAbsolutePathName Method
    • GetBaseName Method
    • GetDrive Method ≡ Drive Object
    • GetDriveName Method
    • GetExtensionName Method
    • GetFile Method [≡ File Object]
    • GetFileVersion Method
    • GetFileName Method
    • GetFolder Method [≡ Folder object]
    • GetParentFolderName Method
    • GetSpecialFolder Method [≡ Folder object]
    • GetStandardStream Method ≡ TextStream object
    • GetTempName Method
    • MoveFile Method
    • MoveFolder Method
    • OpenTextFile Method ≡ TextStream object
  • FileSystemObject Property
    • Drives Property ≡ Drives Collection
  • FileSystemObject Collection
    • Drives Property ≡ Drives Collection

Drives Collection

last updated 12/14/2017

is to provide access to all available drives or network shares inside the file system as a single object.

Syntax

Set fsodrivecolvar=fsoobjvar.Drives

Argument

SetRequired Keyword. to specify the setting of an Object instance reference.rematcolvarRequired. to specify the name of a new Object instance reference for the assigned Obect.fsoobjvarRequired. to specify the associated Object instance reference.DrivesRequired Keyword. to specify the Property of associated Object.

Remarks

  • Removable-media drives need not have media inserted for them to appear in the Drives collection.
  • Read-only collection of all available drives returned from the Drives Property of FileSystemObject Object. In other words, a collection of all available drives from the file system.

Applied to

FileSystemObject Object

Drives Properties

last updated 12/14/2017

Two Properties are predefined for the returns of Drives Property of FileSystemObject Object, namely, Count Property, and Item Property. Dot notation is used to access the available Property for the Drives Collection returned by Drives Property of FileSystemObject Object, for example, fsoobjvar.Drives.propertyname.

Syntax

fsodrivecolvar.Count
fsodrivecolvar.Item(key)

Examples

Examples of FileSystemObject Object

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda
cmda=array("strs")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="Set sysfso = CreateObject(""Scripting.FileSystemObject""): Set strs=sysfso":dsp_x
vars="strs=sysfso.DriveExists(""R:/"")":dsp_x
vars="strs=sysfso.BuildPath(""R:/"",""Z"")":dsp_x
vars="strs=sysfso.CreateFolder(strs)":dsp_x
vars="strs=sysfso.CreateFolder(""R:/Y"")":dsp_x
vars="Set strs=sysfso.CreateFolder(""R:/W"")":dsp_x
vars="strs=sysfso.CopyFolder(""R:/Y"",""R:/Z/Y"",True)":dsp_x
vars="Set strs=sysfso.CreateTextFile(""R:\Z\t1.txt"",True)":dsp_x
vars="strs=sysfso.CopyFile(""R:\Z\t1.txt"",""R:\Z\t2.txt"",True)":dsp_x
vars="strs=sysfso.MoveFile(""R:\Z\t2.txt"",""R:/Z/Y/"")":dsp_x
vars="sysfso.MoveFolder ""R:\W"",""R:\Z\"" ":dsp_x
vars="strs=sysfso.FileExists(""R:\Z\t2.txt"")":dsp_x
vars="strs=sysfso.FolderExists(""R:\Z"")":dsp_x
vars="strs=sysfso.FolderExists(""R:\"")":dsp_x
vars="Set strs=sysfso.OpenTextFile(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.GetAbsolutePathName("""")":dsp_x
vars="strs=sysfso.GetBaseName(""R:\Z"")":dsp_x
vars="Set strs=sysfso.GetDrive(""R:"")":dsp_x
vars="strs=sysfso.GetDriveName(""R:\Z"")":dsp_x
vars="strs=sysfso.GetExtensionName(""R:\Z"")":dsp_x
vars="strs=sysfso.GetFile(""R:\Z\t1.txt"")":dsp_x
vars="Set strs=sysfso.GetFile(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.GetFileVersion(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.GetFileName(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.GetFolder(""R:\Z\"")":dsp_x
vars="Set strs=sysfso.GetFolder(""R:\Z\"")":dsp_x
vars="strs=sysfso.GetParentFolderName(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.GetSpecialFolder(0)":dsp_x
vars="Set strs=sysfso.GetSpecialFolder(0)":dsp_x
vars="Set strs=sysfso.GetStandardStream(1)":dsp_x
vars="strs=sysfso.GetTempName()":dsp_x
vars="Set strs=Nothing: strs=sysfso.DeleteFile(""R:\Z\t1.txt"")":dsp_x
vars="strs=sysfso.DeleteFolder(""R:\Z"")":dsp_x
vars="strs=sysfso.DeleteFolder(""R:\Y"")":dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp
varsstrs, TypeNameSet sysfso = CreateObject("Scripting.FileSystemObject"): Set strs=sysfso[FileSystemObject], FileSystemObjectstrs=sysfso.DriveExists("R:/")[True], Booleanstrs=sysfso.BuildPath("R:/","Z")[R:/Z], Stringstrs=sysfso.CreateFolder(strs)[R:\Z], Stringstrs=sysfso.CreateFolder("R:/Y")[R:\Y], StringSet strs=sysfso.CreateFolder("R:/W")[R:\W], Folderstrs=sysfso.CopyFolder("R:/Y","R:/Z/Y",True)[], EmptySet strs=sysfso.CreateTextFile("R:\Z\t1.txt",True)[TextStream], TextStreamstrs=sysfso.CopyFile("R:\Z\t1.txt","R:\Z\t2.txt",True)[], Emptystrs=sysfso.MoveFile("R:\Z\t2.txt","R:/Z/Y/")[], Emptysysfso.MoveFolder "R:\W","R:\Z\" [], Emptystrs=sysfso.FileExists("R:\Z\t2.txt")[False], Booleanstrs=sysfso.FolderExists("R:\Z")[True], Booleanstrs=sysfso.FolderExists("R:\")[True], BooleanSet strs=sysfso.OpenTextFile("R:\Z\t1.txt")[TextStream], TextStreamstrs=sysfso.GetAbsolutePathName("")[C:\Windows\System32\inetsrv], Stringstrs=sysfso.GetBaseName("R:\Z")[Z], StringSet strs=sysfso.GetDrive("R:")[R:], Drivestrs=sysfso.GetDriveName("R:\Z")[R:], Stringstrs=sysfso.GetExtensionName("R:\Z")[], Stringstrs=sysfso.GetFile("R:\Z\t1.txt")[R:\Z\t1.txt], StringSet strs=sysfso.GetFile("R:\Z\t1.txt")[R:\Z\t1.txt], Filestrs=sysfso.GetFileVersion("R:\Z\t1.txt")[], Stringstrs=sysfso.GetFileName("R:\Z\t1.txt")[t1.txt], Stringstrs=sysfso.GetFolder("R:\Z\")[R:\Z], StringSet strs=sysfso.GetFolder("R:\Z\")[R:\Z], Folderstrs=sysfso.GetParentFolderName("R:\Z\t1.txt")[R:\Z], Stringstrs=sysfso.GetSpecialFolder(0)[C:\Windows], StringSet strs=sysfso.GetSpecialFolder(0)[C:\Windows], FolderSet strs=sysfso.GetStandardStream(1)[TextStream], TextStreamstrs=sysfso.GetTempName()[rad7048D.tmp], StringSet strs=Nothing: strs=sysfso.DeleteFile("R:\Z\t1.txt")[], Emptystrs=sysfso.DeleteFolder("R:\Z")[], Emptystrs=sysfso.DeleteFolder("R:\Y")[], Empty

Sideway BICK Blog

04/06


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013