{"id":1057,"date":"2024-07-04T13:34:00","date_gmt":"2024-07-04T05:34:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1057"},"modified":"2024-07-09T11:47:39","modified_gmt":"2024-07-09T03:47:39","slug":"%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f%e5%af%b9%e8%b1%a1file-system-object%e5%87%bd%e6%95%b0%e7%b3%bb%e5%88%97%e4%b9%8b%e4%b8%80","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1057","title":{"rendered":"\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61(File System Object)\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00"},"content":{"rendered":"\n<p>Public Function GetExeVersion(ByVal sFullName As String) As String &#8216;\u83b7\u53d6\u53ef\u6267\u884c\u6587\u4ef6\u7248\u672c\u53f7<br>Dim FSO As Object<br>GetExeVersion = &#8220;&#8221;<br>If Not FileExist(sFullName) Then Exit Function<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>GetExeVersion = FSO.GetFileVersion(sFullName)<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetExeInfo(ByVal sFullName As String) As String &#8216;\u83b7\u53d6\u53ef\u6267\u884c\u6587\u4ef6\u7684\u4fe1\u606f<br>Dim FSO As Object<br>GetExeInfo = &#8220;&#8221;<br>If Not FileExist(sFullName) Then Exit Function<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>Dim oFile As Object<br>Set oFile = FSO.GetFile(sFullName)<br>GetExeInfo = oFile.Size &#8216;Type\/Attributes\/Name\/Path .etc<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetWindows() As String &#8216;\u83b7\u53d6 Windows<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>GetWindows = FSO.GetSpecialFolder(0)<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetSystem() As String &#8216;\u83b7\u53d6 System<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>GetSystem = FSO.GetSpecialFolder(1)<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetTemporary() As String &#8216;\u83b7\u53d6 Temporary<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>GetTemporary = FSO.GetSpecialFolder(2)<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetFileList(ByVal sFolder As String) As String &#8216;\u83b7\u53d6\u6587\u4ef6\u5939\u672c\u7ea7\u5185\u6240\u6709\u6587\u4ef6<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>Dim oFolder As Object, oItem As Object, oCollection As Object<br>Dim sList As String<br>If FSO.FolderExists(sFolder) Then<br>Set oFolder = FSO.GetFolder(sFolder)<br>Set oCollection = oFolder.Files<br>&#8216;Debug.Print oCollection.Count<br>For Each oItem In oCollection<br>sList = sList &amp; oItem.Name<br>sList = sList &amp; &#8220;|&#8221;<br>Next<br>GetFileList = sList<br>Else<br>GetFileList = &#8220;&#8221;<br>End If<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetFolderList(ByVal sFolder As String) As String &#8216;\u83b7\u53d6\u6587\u4ef6\u5939\u4e0b\u4e00\u7ea7\u6240\u6709\u5b50\u6587\u4ef6\u5939<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>Dim oFolder As Object, oItem As Object, oCollection As Object<br>Dim sList As String<br>If FSO.FolderExists(sFolder) Then<br>Set oFolder = FSO.GetFolder(sFolder)<br>Set oCollection = oFolder.SubFolders<br>&#8216;Debug.Print oCollection.Count<br>For Each oItem In oCollection<br>sList = sList &amp; oItem.Name<br>sList = sList &amp; &#8220;|&#8221;<br>Next<br>GetFolderList = sList<br>Else<br>GetFolderList = &#8220;&#8221;<br>End If<br>Set FSO = Nothing<br>End Function<\/p>\n\n\n\n<p>Public Function GetDrivesList() As String<br>Dim FSO As Object<br>Set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br>Dim oItem As Object, oCollection As Object<br>Dim sList As String<br>Set oCollection = FSO.Drives<br>For Each oItem In oCollection<br>&#8216;Debug.Print oItem.SerialNumber<br>sList = sList &amp; oItem.DriveLetter<br>sList = sList &amp; &#8220;|&#8221;<br>Next<br>GetDrivesList = sList<br>Set FSO = Nothing<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Public Function GetExeVersion(ByVal sFullName As String &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1057\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61(File System Object)\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-1057","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1057"}],"version-history":[{"count":3,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1057\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1057\/revisions\/1144"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}