asp函数FileSystemObject详解

Set fs=Server.CreateObject("Scripting.FileSystemObject")
1.文件是否存在
If (fs.FileExists("c:/winnt/cursors/3dgarro.cur"))=true Then
      Response.Write("File c:/winnt/cursors/3dgarro.cur exists.")
Else
      Response.Write("File c:/winnt/cursors/3dgarro.cur does not exist.")
End If
2.目录是否存在
If fs.FolderExists("c:/temp") = true Then
      Response.Write("Folder c:/temp exists.")
Else
      Response.Write("Folder c:/temp does not exist.")
End If
3.磁盘是否存在
if fs.driveexists("c:") = true then
      Response.Write("Drive c: exists.")
Else
      Response.Write("Drive c: does not exist.")
End If

Response.write("<br>")

if fs.driveexists("g:") = true then
      Response.Write("Drive g: exists.")
Else
      Response.Write("Drive g: does not exist.")
End If

4.获得文件所在的磁盘目录
p=fs.GetDriveName("c:/winnt/cursors/3dgarro.cur")
Response.Write("The drive name is: " & p)
结果:c:
5.获得文件所在的文件目录
p=fs.GetParentFolderName("c:/winnt/cursors/3dgarro.cur")
Response.Write("The parent folder name of c:/winnt/cursors/3dgarro.cur is: " & p)
结果:c:/winnt/cursors
6.获得文件的扩展名
Response.Write(fs.GetExtensionName("c:/winnt/cursors/3dgarro.cur"))
结果:cur
7.获得文件全名
Response.Write(fs.GetFileName("c:/winnt/cursors/3dgarro.cur"))
结果:3dgarro.cur
8.获得文件第一个名称
Response.Write(fs.GetBaseName("c:/winnt/cursors/3dgarro.cur"))
Response.Write("<br />")
Response.Write(fs.GetBaseName("c:/winnt/cursors/"))
Response.Write("<br />")
Response.Write(fs.GetBaseName("c:/winnt/"))
结果:3dgarro
        cursors
        winnt

set fs=nothing
载自:http://www.w3schools.com/asp/default.asp
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值