栏目列表
当前位置: 首页>>化学家园>>习题下载>>同步练习>>文章内容
ASP编程:FileSystemObject对象实例讲解(1)
发布时间:2009-03-12   点击:   来源:捷扬文章管理系统   作者:will2011

指定的文件存在吗?

本例演示如何首先创建FileSystemObject对象,然后使用FileExists方法来探测某文件是否存在。
本示例代*如下:

Example Source Code

<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\windows\cursors\***.cur"))=true Then
Response.Write("文件 c:\windows\cursors\***.cur 存在。")
Else
      Response.Write("文件 c:\windows\cursors\***.cur 不存在。")
End If
set fs=nothing
%>
</body>
</html>


本实例运行结果如下:
文件 c:\windows\cursors\***.cur 不存在。

指定的文件夹存在吗?

本例演示如何使用FolderExists方法探测某文件夹是否存在。
本示例代*如下:

Example Source Code

<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If fs.FolderExists("c:\temp") = true Then
      Response.Write("文件夹 c:\temp 存在。")
Else
      Response.Write("文件夹 c:\temp 不存在。")
End If
set fs=nothing
%>
</body>
</html>


本实例运行结果如下:
 文件夹 c:\temp 不存在。

指定的驱动器存在吗?

本例演示如何使用DriveExists方法来探测某个驱动器是否存在。
本示例代*如下:

Example Source Code

<html>
<body>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.driveexists("c:") = true then
      Response.Write("驱动器 c: 存在。")
Else
      Response.Write("驱动器 c: 不存在。")
End If
Response.write("<br>")
if fs.driveexists("g:") = true then
      Response.Write("驱动器 g: 存在。")
Else
      Response.Write("驱动器 g: 不存在。")
End If
set fs=nothing
%>
</body>
</html>


 

本实例运行结果如下:
驱动器 c: 存在。
驱动器 g: 存在。

 

关闭窗口
打印文档
附件:

    主办单位:常州市新北区奔牛初级中学    苏ICP备10201501号-3
    地址:常州市新北区奔牛中天南路61号
    技术支持:新北区教师发展中心、常州万兆网络科技有限公司    访问统计