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
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