對于文件,以字節(jié)為單位返回指定文件的大小。對于文件夾,以字節(jié)為單位返回文件夾中包含的所有文件和子文件夾的大小。
object.Size
object 應(yīng)為 File 或 Folder 對象。
下面的代碼通過一個(gè) Folder 對象說明了 Size 屬性的用法:
[JScript] function ShowFolderSize(filespec) { var fso, f, s; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFolder(filespec); s = f.Name + " uses " +f.size
+ " bytes."; return(s); } [VBScript] Function ShowFolderSize(filespec) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(filespec) s = UCase(f.Name) & " uses " &f.size
& " bytes." ShowFolderSize = s End Function
Attributes 屬性 | DateCreated 屬性 | DateLastAccessed 屬性 | DateLastModified 屬性 | Drive 屬性 | Files 屬性 | IsRootFolder 屬性 | Name 屬性 | ParentFolder 屬性 | Path 屬性 | ShortName 屬性 | ShortPath 屬性 | SubFolders 屬性 | Type 屬性