{"id":231,"date":"2006-04-28T15:02:35","date_gmt":"2006-04-28T15:02:35","guid":{"rendered":"http:\/\/fanhaijun.com\/?p=231"},"modified":"2006-04-28T15:02:35","modified_gmt":"2006-04-28T15:02:35","slug":"fso%e6%96%87%e4%bb%b6%e5%af%b9%e8%b1%a1%e4%bb%8b%e7%bb%8d%e5%8f%8a%e5%b8%b8%e7%94%a8%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/fanhaijun.com\/?p=231","title":{"rendered":"FSO\u6587\u4ef6\u5bf9\u8c61\u4ecb\u7ecd\u53ca\u5e38\u7528\u51fd\u6570"},"content":{"rendered":"<p>FSO\u7684\u610f\u601d\u662fFileSystemObject\uff0c\u5373\u6587\u4ef6\u7cfb\u7edf\u5bf9\u8c61\u3002FSO\u5bf9\u8c61\u6a21\u578b\u5305\u542b\u5728Scripting&nbsp;\u7c7b\u578b\u5e93&nbsp;(Scrrun.Dll)\u4e2d\uff0c\u5b83\u540c\u65f6\u5305\u542b\u4e86Drive\u3001Folder\u3001File\u3001FileSystemObject\u548cTextStream\u4e94\u4e2a\u5bf9\u8c61\uff0c\u7528\u6765\u64cd\u4f5c\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u5341\u5206\u65b9\u4fbf\u3002<\/p>\n<p>FSO\u6587\u4ef6\uff08File\uff09\u5bf9\u8c61\u5c5e\u6027<\/p>\n<p>\u5c5e&nbsp;\u6027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8bf4&nbsp;\u660e<br \/>DateCreated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u8be5\u6587\u4ef6\u5939\u7684\u521b\u5efa\u65e5\u671f\u548c\u65f6\u95f4<br \/>DateLastAccessed&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u6700\u540e\u4e00\u6b21\u8bbf\u95ee\u8be5\u6587\u4ef6\u7684\u65e5\u671f\u548c\u65f6\u95f4<br \/>DateLastModified&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u6700\u540e\u4e00\u6b21\u4fee\u6539\u8be5\u6587\u4ef6\u7684\u65e5\u671f\u548c\u65f6\u95f4<br \/>Drive&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u8be5\u6587\u4ef6\u6240\u5728\u7684\u9a71\u52a8\u5668\u7684Drive\u5bf9\u8c61<br \/>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8bbe\u5b9a\u6216\u8fd4\u56de\u6587\u4ef6\u7684\u540d\u5b57<br \/>ParentFolder&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u8be5\u6587\u4ef6\u7684\u7236\u6587\u4ef6\u5939\u7684Folder\u5bf9\u8c61<br \/>Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u53ef\u4f7f\u7528\u957f\u6587\u4ef6\u540d<br \/>ShortName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56deDOS\u98ce\u683c\u76848.3\u5f62\u5f0f\u7684\u6587\u4ef6\u540d<br \/>ShortPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56deDOS\u98ce\u683c\u76848.3\u5f62\u5f0f\u7684\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84<br \/>Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd4\u56de\u8be5\u6587\u4ef6\u7684\u5927\u5c0f\uff08\u5b57\u8282\uff09<br \/>Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5982\u679c\u53ef\u80fd\uff0c\u8fd4\u56de\u4e00\u4e2a\u6587\u4ef6\u7c7b\u578b\u7684\u8bf4\u660e\u5b57\u7b26\u4e32<\/p>\n<p>FSO\u6587\u4ef6\uff08File\uff09\u5bf9\u8c61\u65b9\u6cd5<\/p>\n<p>FSO\u6587\u4ef6\u5bf9\u8c61\u65b9\u6cd5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u7528\u9014<br \/>CopyFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u62f7\u8d1d\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u6587\u4ef6\u5230\u65b0\u8def\u5f84<br \/>CreateTextFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u521b\u5efa\u6587\u4ef6\u5e76\u4e14\u8fd4\u56de\u4e00\u4e2aTextStream\u5bf9\u8c61<br \/>DeleteFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5220\u9664\u4e00\u4e2a\u6587\u4ef6<br \/>OpenTextFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6253\u5f00\u6587\u4ef6\u5e76\u4e14\u8fd4\u56deTextStream\u5bf9\u8c61\uff0c\u4ee5\u4fbf\u8bfb\u53d6\u6216\u8005\u8ffd\u52a0<\/p>\n<p>\u91cd\u547d\u540d\u6587\u4ef6\uff1a<\/p>\n<p>\u5f15\u7528\u5185\u5bb9\uff1a<br \/>Function&nbsp;reName(sourceName,destName)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;oFso,oFile<br \/>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;oFso=server.createobject(&quot;Scripting.FileSystemObject&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;oFile=oFso.getFile(Server.mappath(sourceName))<br \/>&nbsp;&nbsp;&nbsp;&nbsp;oFile.Name=destName<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;oFso=Nothing<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;oFile=Nothing<br \/>End&nbsp;Function<\/p>\n<p>\u5220\u9664\u6587\u4ef6<\/p>\n<p>\u5f15\u7528\u5185\u5bb9\uff1a<br \/>Function&nbsp;FSOdel(fileName)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;fso,f<br \/>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;fso&nbsp;=&nbsp;server.CreateObject(&quot;scripting.filesystemobject&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;f=server.MapPath(fileName)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;fso.FileExists(f)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fso.DeleteFile&nbsp;f,true<br \/>&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;if<br \/>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;f&nbsp;=&nbsp;nothing<br \/>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;fso&nbsp;=&nbsp;nothing<br \/>End&nbsp;Function<\/p>\n<p>\u66ff\u6362\u6587\u4ef6\u4e2d\u7684\u5b57\u7b26\u4e32<\/p>\n<p>\u5f15\u7528\u5185\u5bb9\uff1a<br \/>Function&nbsp;FSOreplace(fileName,Target,repString)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;objFSO,objCountFile,FiletempData<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;objFSO&nbsp;=&nbsp;Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;objCountFile&nbsp;=&nbsp;objFSO.OpenTextFile(Server.MapPath(fileName),1,True)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;FiletempData&nbsp;=&nbsp;objCountFile.ReadAll<br \/>&nbsp;&nbsp;&nbsp;&nbsp;objCountFile.Close<br \/>&nbsp;&nbsp;&nbsp;&nbsp;FiletempData=Replace(FiletempData,Target,repString)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;objCountFile=objFSO.CreateTextFile(Server.MapPath(fileName),True)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;objCountFile.Write&nbsp;FiletempData<br \/>&nbsp;&nbsp;&nbsp;&nbsp;objCountFile.Close<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;objCountFile=Nothing<br \/>&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;objFSO&nbsp;=&nbsp;Nothing<br \/>End&nbsp;Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FSO\u7684\u610f\u601d\u662fFileSystemObject\uff0c\u5373\u6587\u4ef6\u7cfb\u7edf\u5bf9&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[100],"tags":[],"class_list":["post-231","post","type-post","status-publish","format-standard","hentry","category-nothing"],"_links":{"self":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":0,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"wp:attachment":[{"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanhaijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}