ASP实例教程:FileSystemObject对象
FileSystemObject 对象
指定的文件存在吗?
本例演示如何首先创建FileSystemObject对象,然后使用FileExists方法来探测某文件是否存在。
本示例代码如下:
以下为引用的内容:
<html>
< body>
< %
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\windows\cursors\xxx.cur"))=true Then
Response.Write("文件 c:\windows\cursors\xxx.cur 存在。")
Else
Response.Write("文件 c:\windows\cursors\xxx.cur 不存在。")
End If
set fs=nothing
%>
< /body>
< /html>
本实例运行结果如下:
文件 c:\windows\cursors\xxx.cur 不存在。
指定的文件夹存在吗?
本例演示如何使用FolderExists方法探测某文件夹是否存在。
本示例代码如下:
以下为引用的内容:
<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方法来探测某个驱动器是否存在。
本示例代码如下:
以下为引用的内容:
<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: 存在。
取得某个指定驱动器的名称
本例演示如何使用GetDriveName方法来取得某个指定的驱动器的名称。
本示例代码如下:
以下为引用的内容:
<html>
< body>
< %
Set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.GetDriveName("c:\windows\cursors\abc.cur")
Response.Write("驱动器名称是:"& p)
set fs=nothing
%>
< /body>
< /html>
本实例运行结果如下:
驱动器名称是:c:
取得某个指定路径的父文件夹的名称
本例演示如何使用GetParentFolderName方法来取得某个指定的路径的父文件夹的名称。
本示例代码如下:
以下为引用的内容:
<html>
< body>
< %
Set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.GetParentFolderName("c:\winnt\cursors\3dgarro.cur")
Response.Write("c:\windows\cursors\abc.cur 的父文件夹名称是:"& p)
set fs=nothing
%>
< /body>
< /html>
本实例运行结果如下:
c:\windows\cursors\abc.cur 的父文件夹名称是:c:\winnt\cursors
取得文件夹扩展名
本例演示如何使用GetExtensionName方法来取得指定的路径中的最后一个成分的文件扩展名。
本示例代码如下:
以下为引用的内容:
<html>
< body>
< %
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Response.Write("文件 3dgarro 的文件扩展名是:")
Response.Write(fs.GetExtensionName("c:\windows\cursors\abc.cur"))
set fs=nothing
%>
< /body>
< /html>
本实例运行结果如下:
文件 3dgarro 的文件扩展名是:cur
取得文件名
本例演示如何使用GetFileName方法来取得指定的路径中的最后一个成分的文件名。
关键词:ASP,FileSystemObject
相关阅读
- 07-28asp版百度ueditor在线编辑器上传图片错误(无权限问题修复)
- 05-05Windows2008 64位IIS7+ACCESS数据库无法打开Asp页面
- 05-05win7 iis7.5 Request 对象 错误 'ASP 0104 : 80004005'
- 10-16"Request 对象 错误 'ASP 0104 : 80004005'”解决办法
- 05-03Win7 IIS7.5配置解决ASP的500错误
- 04-07ASP和PHP的区别所在
- 03-09aspx文件怎么打开,ASPX的文件用什么打开?
- 03-04301转向代码大合集 包括IIS、apache和PHP程序/asp程序的301转向设置
- 02-28asp.net“服务器应用程序不可用"解决方法
- 09-24修改IIS的 ASPMaxRequestEntityAllowed
阅读本文后您有什么感想? 已有 人给出评价!
用户评论
热门评论
最新评论
相关软件
热点图文
- 05-02解决:错误提示:Microsoft OLE DB Provider for ODBC Drivers (0x80004005) ...不能更新
- 05-02解决:ADODB.Stream 错误 '800a0bbc' 写入文件失败
- 07-28asp版百度ueditor在线编辑器上传图片错误(无权限问题修复)
- 04-08对象不支持此属性或方法: 'Response.CharSet'
- 04-13asp是什么文件/asp是什么意思/asp是什么格式
- 05-11asp将access数据导出为excel电子表的方法
- 06-14ASP实例教程:FileSystemObject对象
- 07-14使用NetBox编译asp 完全摆脱iis束缚
- 01-10ASP连接Excel文件的方法
- 07-17Microsoft JET Database Engine 错误 '80004005' 错误解决办法