{"id":1239,"date":"2024-07-22T08:00:00","date_gmt":"2024-07-22T00:00:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1239"},"modified":"2024-07-18T09:38:20","modified_gmt":"2024-07-18T01:38:20","slug":"%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0%e7%b3%bb%e5%88%97%e4%b9%8b%e4%ba%8c","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1239","title":{"rendered":"\u5b57\u7b26\u4e32\u51fd\u6570\u7cfb\u5217\u4e4b\u4e8c"},"content":{"rendered":"\n<p>Public Function ReplaceMultiChar(ByVal sData As String, ByVal sChar As String) As String &#8216;\u7528\u5355\u5b57\u7b26\u66ff\u6362\u8fde\u7eed\u5b57\u7b26<br>sData = Trim(sData)<br>Dim iBefore, iAfter As Integer<br>Do<br>iBefore = Len(sData)<br>sData = Replace(sData, sChar &amp; sChar, sChar)<br>iAfter = Len(sData)<br>Loop Until iBefore = iAfter<br>ReplaceMultiChar = sData<br>End Function<\/p>\n\n\n\n<p>Public Function GetExtension(ByVal sName As String) As String &#8216;\u6269\u5c55\u540d<br>GetExtension = &#8220;&#8221;<br>If InStr(1, sName, &#8220;.&#8221;, vbTextCompare) = 0 Then Exit Function<br>Dim TempArray As Variant<br>TempArray = Split(sName, &#8220;.&#8221;, -1, vbTextCompare) &#8216;\u540d\u5b57\u53ef\u80fd\u4f1a\u542b .<br>GetExtension = TempArray(UBound(TempArray)) &#8216;\u6269\u5c55\u540d<br>End Function<\/p>\n\n\n\n<p>Public Function GetBare(ByVal sName As String) As String &#8216;\u4e0d\u5e26\u6269\u5c55\u540d\u7684\u540d<br>GetBare = &#8220;&#8221;<br>If InStr(1, sName, &#8220;.&#8221;, vbTextCompare) = 0 Then Exit Function<br>Dim TempArray As Variant<br>TempArray = Split(sName, &#8220;.&#8221;, -1, vbTextCompare) &#8216;\u540d\u5b57\u53ef\u80fd\u4f1a\u542b .<br>ReDim Preserve TempArray(LBound(TempArray) To UBound(TempArray) &#8211; 1) &#8216;\u53bb\u6269\u5c55\u540d<br>GetBare = Join(TempArray, &#8220;.&#8221;)<br>End Function<\/p>\n\n\n\n<p>Public Function GetFullName(ByVal sPath As String, ByVal sShortName As String) As String &#8216;\u6587\u4ef6\u5168\u540d<br>&#8216;If Right(sPath, 1) = &#8220;\\&#8221; Then<br>&#8216;GetFullName = sPath &amp; sShortName<br>&#8216;Else<br>&#8216;GetFullName = sPath &amp; &#8220;\\&#8221; &amp; sShortName<br>&#8216;End If<br>&#8216;\u4e0b\u53e5\u7b49\u540c\u4ee5\u4e0a\u5185\u5bb9<br>GetFullName = IIf(Right(sPath, 1) = &#8220;\\&#8221; Or Left(sShortName, 1) = &#8220;\\&#8221;, sPath &amp; sShortName, sPath &amp; &#8220;\\&#8221; &amp; sShortName)<br>GetFullName = ReplaceMultiChar(GetFullName, &#8220;\\&#8221;)<br>End Function<\/p>\n\n\n\n<p>Public Function GetShortName(ByVal sFullName As String) As String &#8216;\u6587\u4ef6\u77ed\u540d<br>If sFullName = &#8220;&#8221; Then<br>GetShortName = &#8220;&#8221;<br>Else<br>Dim TempArray As Variant<br>TempArray = Split(sFullName, &#8220;\\&#8221;, -1, vbTextCompare)<br>GetShortName = TempArray(UBound(TempArray))<br>End If<br>End Function<\/p>\n\n\n\n<p>Public Function GetPath(ByVal sFullName As String) As String &#8216;\u6587\u4ef6\u8def\u5f84<br>&#8216;Dim I As Integer<br>&#8216;For I = Len(sFullName) To 1 Step -1<br>&#8216;If Mid(sFullName, I, 1) = &#8220;\\&#8221; Then<br>&#8216;GetPath = Left(sFullName, I &#8211; 1)<br>&#8216;Exit Function<br>&#8216;End If<br>&#8216;Next I<br>Dim TempArray As Variant<br>TempArray = Split(sFullName, &#8220;\\&#8221;, -1, vbTextCompare)<br>If LBound(TempArray) = UBound(TempArray) Then &#8216;\u77ed\u540d<br>GetPath = &#8220;&#8221;<br>Else<br>ReDim Preserve TempArray(LBound(TempArray) To UBound(TempArray) &#8211; 1) As String<br>GetPath = Join(TempArray, &#8220;\\&#8221;)<br>End If<br>End Function<\/p>\n\n\n\n<p>Public Function GetShortPath(ByVal sFullName As String) As String &#8216;\u6587\u4ef6\u5f53\u524d\u6587\u4ef6\u5939<br>Dim TempArray As Variant<br>TempArray = Split(sFullName, &#8220;\\&#8221;, -1, vbTextCompare)<br>GetShortPath = TempArray(UBound(TempArray) &#8211; 1)<br>End Function<\/p>\n\n\n\n<p>Public Function DirExist(ByVal sData As String) As Boolean &#8216;(\u5168\u540d)\u76ee\u5f55\u5b58\u5728<br>DirExist = False<br>If Trim(sData) = &#8220;&#8221; Then Exit Function &#8216;Dir(&#8220;&#8221;) \u51fa\u9519, \u4e14\u65e0\u58f0\u65e0\u606f<br>If Dir(sData, vbDirectory) = &#8220;&#8221; Then Exit Function &#8216;\u4e0d\u5b58\u5728<br>If Not (GetAttr(sData) And vbDirectory) = vbDirectory Then Exit Function &#8216;\u662f\u6587\u4ef6<br>DirExist = True<br>End Function<\/p>\n\n\n\n<p>Public Function FileExist(ByVal sData As String) As Boolean &#8216;(\u5168\u540d)\u6587\u4ef6\u5b58\u5728<br>FileExist = False<br>If Trim(sData) = &#8220;&#8221; Then Exit Function &#8216;Dir(&#8220;&#8221;) \u51fa\u9519, \u4e14\u65e0\u58f0\u65e0\u606f<br>If Dir(sData) = &#8220;&#8221; Then Exit Function &#8216;\u4e0d\u5b58\u5728<br>If (GetAttr(sData) And vbDirectory) = vbDirectory Then Exit Function &#8216;\u662f\u76ee\u5f55<br>FileExist = True<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Public Function ReplaceMultiChar(ByVal sData As String, &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1239\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5b57\u7b26\u4e32\u51fd\u6570\u7cfb\u5217\u4e4b\u4e8c\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-1239","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\/1239","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=1239"}],"version-history":[{"count":2,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1239\/revisions"}],"predecessor-version":[{"id":1334,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1239\/revisions\/1334"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}