返回關(guān)于文件或文件夾類型的信息。例如,對(duì)于以 .TXT 結(jié)尾的文件將返回“文本文檔”。
object.Type
object 應(yīng)為 File 或 Folder 對(duì)象。
下面的代碼說明了利用 Type 屬性返回文件夾屬性的方法。在這個(gè)例子中,可以嘗試一下向過程提供回收站或其他特殊文件夾的路徑。
[JScript] function ShowFileType(filespec) { var fso, f, s; fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FolderExists(filespec)) f = fso.GetFolder(filespec); else if (fso.FileExists(filespec)) f = fso.GetFile(filespec); else s = "File or Folder does not exist."; s = f.Name + " is a " +f.Type
; return(s); } [VBScript] Function ShowFolderType(filespec) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(filespec) s = UCase(f.Name) & " is a " &f.Type
ShowFolderType = s End Function
Attributes 屬性 | DateCreated 屬性 | DateLastAccessed 屬性 | DateLastModified 屬性 | Drive 屬性 | Files 屬性 | IsRootFolder 屬性 | Name 屬性 | ParentFolder 屬性 | Path 屬性 | ShortName 屬性 | ShortPath 屬性 | Size 屬性 | SubFolders 屬性
應(yīng)用于:File 對(duì)象 | Folder 對(duì)象