<p>系统对象FSO的英文全称是File System Object ,这种对象模型提出了有别于传统的文件操作语句处理文件和文件夹的方法。通过采用object.method这种在面向对象编程中广泛使用的语法,将一系列操作文件和文件夹的动作通过调用对象本身的属性直接实现。</p> <div class="floatAd" id="c_ads5"></div> <div class="rightAd" id="c_ads6"></div> <p>件系统对象fso的英文全称是file system object ,这种对象模型提出了有别于传统的文件操作语句处理文件和文件夹的方法。通过采用object.method这种在面向对象编程中广泛使用的语法,将一系列操作文件和文件夹的动作通过调用对象本身的属性直接实现。</p> <blockquote> <p></p> </blockquote> <p> <p><br /> &lt;%<br /> set fs=server.createobject(&quot;scripting.filesystemobject&quot;)<br /> if (fs.fileexists(&quot;c:windowscursorsxxx.cur&quot;))=true then<br /> response.write(&quot;文件 c:windowscursorsxxx.cur 存在。&quot;)<br /> else<br /> response.write(&quot;文件 c:windowscursorsxxx.cur 不存在。&quot;)<br /> end if<br /> set fs=nothing<br /> %&gt;</p> </p> <p></p> <p> <p> <p> <p><br /> &lt;%<br /> set fs=server.createobject(&quot;scripting.filesystemobject&quot;)<br /> if fs.folderexists(&quot;c:temp&quot;) = true then<br /> response.write(&quot;文件夹 c:temp 存在。&quot;)<br /> else<br /> response.write(&quot;文件夹 c:temp 不存在。&quot;)<br /> end if<br /> set fs=nothing<br /> %&gt;</p> </p> </p> </p> <p> <p></p> <br /> <br /> &lt;%<br /> set fs=server.createobject(&quot;scripting.filesystemobject&quot;)<br /> if fs.driveexists(&quot;c:&quot;) = true then<br /> response.write(&quot;驱动器 c: 存在。&quot;)<br /> else<br /> response.write(&quot;驱动器 c: 不存在。&quot;)<br /> end if<br /> response.write(&quot;<br /> &quot;)<br /> if fs.driveexists(&quot;g:&quot;) = true then<br /> response.write(&quot;驱动器 g: 存在。&quot;)<br /> else<br /> response.write(&quot;驱动器 g: 不存在。&quot;)<br /> end if<br /> set fs=nothing<br /> %&gt;<br /> </p> <p>由于fso对象包含在scripting 类型库 (scrrun.dll)中,所以在使用前首先需要在在工程中引用这个文件,单击&ldquo;工程&rdquo;,&ldquo;引用&rdquo;,然后在&ldquo;引用&rdquo;对话框中选中&ldquo;microsoft scripting runtime&rdquo;前的复选框,然后单击&ldquo;确定&rdquo;。</p> <div class="spctrl"></div> <p>  要创建fso对象可以采用两种方法,一种是将一个变量声明为fso对象类型:dim fsotest as new filesystemobject;另一种是通过createobject方法创建一个fso 对象:set fsotest = createobject(&ldquo;scripting.filesystemobject&quot;)。在实际使用中具体采用哪种声明方法,可根据个人的使用习惯而定。</p> <div class="spctrl"></div> <p>  完成了fso对象模型的创建之后,就可以利用创建的对象模型的方法访问下属各个对象的属性来获取所需信息或进行相关操作了,具体的方法在下面结合各个对象分别讲述</p>
T:0.006490s,M:247.98 KB
返回顶部 留言