请问这段代码怎么写?(急用)
请问这段代码怎么写?(急用)
<%
Dim fso,f, f1, fc, s,fpath
fpath="e:\123" ' 此处设置你要查看目录
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(fpath)
Set fc = f.Files
asdf=f.ShortPath
%>
<form name="form1">
<select name="type" >
<option value="名称">文件列表</option>
<%
For Each f1 in fc '显示文件
s = f1.name
vfilepath=asdf & "\" & s
response.write "<option value='file'>" & s & "</option>"
Next
%>
</select>
</form>
Microsoft VBScript 运行时错误 错误 '800a01ad'
ActiveX 部件不能创建对象: 'Scripting.FileSystemObject'
/admin/ChanPinFenLei.asp,行 212
报这个错,怎么办?
版主我把您说的路径给改成相对路径了但还是有问题您看看这样改对吗?
<%Dim fso,f, f1, fc, s,fpath
Dim tempCurrentPath,CurrentPath,DirectoryRoot
DirectoryRoot=Trim(Request("DirectoryRoot"))
if DirectoryRoot="" or DirectoryRoot="/" then
DirectoryRoot = "/"
else
if right(DirectoryRoot,1)<>"/" then
DirectoryRoot = DirectoryRoot&"/"
end if
end if
qlj=trim(request("qlj"))
fjx="DirectoryRoot="&DirectoryRoot&"&qlj="&qlj
tempCurrentPath=FilterPath(Trim(Request("CurrentPath"))) ‘19行
If tempCurrentPath<>"" Then
if instrrev(tempCurrentPath,"/")=0 then
ParentFolder=""
else
ParentFolder=left(tempCurrentPath,instrrev(tempCurrentPath,"/")-1)
end if
Else
ParentFolder=tempCurrentPath
End If
if tempCurrentPath<>"" and left(tempCurrentPath,1)="/" then
tempCurrentPath = mid(tempCurrentPath,2)
end if
if tempCurrentPath<>"" and right(tempCurrentPath,1)<>"/" then
tempCurrentPath = tempCurrentPath&"/"
end if
If tempCurrentPath="" Then
CurrentPath=DirectoryRoot
Else
CurrentPath=DirectoryRoot & tempCurrentPath
End If
If Fso.FolderExists(Server.MapPath(CurrentPath)) Then
'获得虚拟文件系统主目录DirectoryRoot
Set Fol=Fso.GetFolder(Server.MapPath(CurrentPath))
Else
'若虚拟文件系统主目录未找到,则创建该目录
If CurrentPath=DirectoryRoot Then
Fso.CreateFolder(Server.MapPath(CurrentPath))
Set Fol=Fso.GetFolder(Server.MapPath(CurrentPath))
End If
End If
'fpath="E:\公共\duihao.net\duihao.net\chengxu\FileSystem" ' 此处设置你要查看目录
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(CurrentPath)
Set fc = f.Files
asdf=f.ShortPath
For Each f1 in fc '显示文件
s = f1.name
vfilepath=asdf & "\" & s
response.write "<option value='file'>" & s & "</option>"
Next%>
报错地方是
Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: 'FilterPath'
/admin/ChanPinFenLei.asp,行 19
这里是要用绝对路径的,
如果是想对路径你自已想办法转成绝对路径才能读出文件.
可看一下我以前写的一个文件,里面FSO用的比较多:
http://www.bc-cn.net/bbs/boke.asp?icecool.showtopic.822.html