当前位置: 首页 > 学习 > 电脑学习 > 网站开发 > ASP > ASP技巧 > 正文

回复: kw,你的那个程序不能用绝对路径?如c:\

http://www.zk168.com.cn  招考学习网 2006-4-30 12:31:56
-----------------------------------------------------------[交流]-[打印]-[发送]-[收藏]--
1. 其实我现在使用的就是一个比较完整的。代码见下:
2. 由于需要在两天之内写出来(the whole site),代码很不漂亮,也没有 err handle, optimize.
3. filesystemobject 只能用绝对路径。所以需要 mappath method.
4. Microsoft suminfo object 只支持本地文件,不能 net use...
5. 但是他有 c++ 的源代码,你可以...
6. 很抱歉没办法把整个站点和大家共享,因为在Intranet.
7. 为了对大家负责,我又看了一遍这段半年前的代码,好烂。 :-)
凑和用 8。 :-)
=================================
<%@ Language=VBScript %>
<%
' *********************************************************
'  this file is written by
'  kw copyright reserved. :-)
'  if you have any question, directly contact w/ me.
'  some features are just under construction...
' *********************************************************
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK REL="stylesheet" TYPE="text/css" HREF="/css/myCSS.CSS">
</HEAD>
<BODY>

<SCRIPT LANGUAGE=javascript>
<!--
  function mousemove()
  {
    var srcElement;
    srcElement=window.event.srcElement;
    {
      srcElement.className = "coolstyle";
    }
  }

  function mouseout()
  {
    var srcElement;
    srcElement=window.event.srcElement;
    {
      srcElement.className = "normalstyle";
    }
  }

//-->
</SCRIPT>



<SCRIPT LANGUAGE=vbscript RUNAT = Server>

    ' Virtual Root
    FileServerName = "fileserver"
    VRoot = "/file"

    ' Get the files collection from current folder
    dim fs, f, f1, fc, s
    set fs = createobject("scripting.filesystemobject")

' begin of function - to get path info from external
    ' get Path parameter from external
    sPath = Request("sPath")
    if (sPath = "" or sPath = ".") then
        sPath = "."
        Response.Write "<TABLE class = tablefilename border=0 width='100%'>"
        Response.Write "<TR align=center>"
        sHelloString = "Hi, guy, i didn't get correct path info, so I can only show you current folder"
        Response.Write "<TD>" & sHelloString & "</TD></TR></TABLE>"
    end if
    ' merge Absolute path
    sAbPath = server.MapPath (".") & "/" & sPath
    set f = fs.GetFolder (sAbPath)
' end of function - to get path info from external

    set fc = f.files
    ' Create suminfo object
    dim suminfo
    set SumInfo = Server.CreateObject("IISSample.SummaryInfo")
    
    ' Which kinds of document should be displayed?
    '
    bDocChecked = Request.Form ("doc")
    bXDocChecked = Request("XDoc")
    
    bPptChecked = Request.Form ("ppt")
    bXPptChecked = Request("XPpt")
    
    bXlsChecked = Request.Form ("xls")
    bXXlsChecked = Request("XXls")
    
    bTxtChecked = Request.Form ("txt")
    bXTxtChecked = Request("XTxt")
    
    bZipChecked = Request.Form ("zip")
    bXZipChecked = Request("XZip")
    
    ' Display all document in the folder is dangerous, so...
    'bAllChecked = Request.Form ("all")
    
    ' Tell the visitor how to display document
    Response.Write "<TABLE class = tablefilename border=0 width='100%'>"

    Response.Write "<TR align=center><TD>"
    Response.Write "<font color=navy>"
    Response.Write "Current folder: <a href='file://" &  FileServerName & VRoot & "/" & sPath & "' target='_blank'>"
    Response.Write "<span onmousemove='mousemove()' onmouseout='mouseout()'>"
    Response.Write "//" & FileServerName & VRoot & "/" & sPath & "</a>"
    Response.Write "</span>"
    Response.Write "</font>"
    Response.Write "</TD></TR>"


    Response.Write "<TR align=center><TD>"
    Response.Write "<font color=green>Please select the document type you want to list, and click Refresh</font>"
    Response.Write "</TD></TR>"

    Response.Write "<TR align=center><TD>"
    Response.Write "<FORM action='display.asp" & "?sPath=" & sPath & "' id=choose_doc_type method=post name=FORM1>"
    Response.Write "<INPUT id=checkbox1 name=doc type=checkbox "
    if ( bDocChecked = "on" or bXDocChecked = "on" ) then Response.Write "checked"
    Response.Write ">Word"
    Response.Write "<INPUT id=checkbox2 name=ppt type=checkbox "
    if ( bPptChecked = "on" or bXPptChecked = "on" ) then Response.Write "checked"
    Response.Write ">Powerpoint"
    Response.Write "<INPUT id=checkbox3 name=xls type=checkbox "
    if ( bXlsChecked = "on" or bXXlsChecked = "on" ) then Response.Write "checked"
    Response.Write ">Excel"
    Response.Write "<INPUT id=checkbox4 name=txt type=checkbox "
    if ( bTxtChecked = "on" or bXTxtChecked = "on" ) then Response.Write "checked"
    Response.Write ">Text"
    Response.Write "<INPUT id=checkbox5 name=zip type=checkbox "
    if ( bZipChecked = "on" or bXZipChecked = "on" ) then Response.Write "checked"
    Response.Write ">Zip"
    ' Display all document in the folder is dangerous, so...
    'Response.Write "<INPUT id=checkbox6 name=all type=checkbox "
    'if bAllChecked = "on" then Response.Write "checked"
    'Response.Write ">All"
    Response.Write "<INPUT id=submit1 name=submit1 type=submit value=Refresh>"
    Response.Write "</FORM>"
    Response.Write "</TD></TR>"
    Response.Write "</TABLE>"
    
    ' list files & properties, one by one
    ' ===================================
    ' first above all, display table header
    Response.Write "<TABLE border=0 width='100%'>"
    
    for each f1 in fc
        ' get file name
        s = f1.name
        ' get file type
        filetype = right(s,3)
        bDisplay = false
        if filetype = "doc" and ( bDocChecked = "on" or bXDocChecked = "on" ) then bDisplay = true
        if filetype = "ppt" and ( bPptChecked = "on" or bXPptChecked = "on" ) then bDisplay = true
        if filetype = "xls" and ( bXlsChecked = "on" or bXXlsChecked = "on" ) then bDisplay = true
        if filetype = "txt" and ( bTxtChecked = "on" or bXTxtChecked = "on" ) then bDisplay = true
        if filetype = "zip" and ( bZipChecked = "on" or bXZipChecked = "on" ) then bDisplay = true
        ' Display all document in the folder is dangerous, so...
        'if bAllChecked = "on" then bDisplay = true

        if bDisplay = true then
        
        ' get this file's properties

        suminfo.SetFile sPath & "/" & s
        ' first, display this file's icon & name
        Response.Write "<TR><TD colspan=2 display icon according to file type
        select case filetype
        case "xls": RESPONSE.Write "<img SRC=" & VRoot & "/images/xls.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case "doc": RESPONSE.Write "<img SRC=" & VRoot & "/images/doc.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case "mdb": RESPONSE.Write "<img SRC=" & VRoot & "/images/mdb.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case "ppt": RESPONSE.Write "<img SRC=" & VRoot & "/images/ppt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case "url": RESPONSE.Write "<img SRC=" & VRoot & "/images/url.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case "zip": RESPONSE.Write "<img SRC=" & VRoot & "/images/txt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        case else : RESPONSE.Write "<img SRC=" & VRoot & "/images/txt.gif WIDTH=16 HEIGHT=16 SPACE=11>"
        end select
        
        Response.Write "<span onmousemove='mousemove()' onmouseout='mouseout()'>"
        Response.Write "<a href='" & sPath & "/" & s & "'></span>" & s & "</a>"
        
        ' it's funny that only ppt has bytes property
        if filetype = "ppt" then Response.Write " (file size: " & suminfo.Bytes & ")"

        ' begin of function - to see if the doc is new, for example, in near 5 days
        ' there's once very important, to confirm that your system time looks like
        ' "Thursday, November 20, 1997, 5:02:45 PM"
        ' otherwise you'll get error
        ' to avoid the error, please change long time format to
        '   dddd, MM dd, yyyy
        ' on SC NT Server
        'get first ","
        dim sLST, iPos_fisrtcomm, iPos_secondcomm
        ' now it's like "Thursday, November 20, 1997, 5:02:45 PM"
        sLST = suminfo.LastSaveTime

        iPos_fisrtcomm = instr (1, sLST, ",")
        ' make it's like "November 20, 1997, 5:02:45 PM"
        sLST = right (sLST ,(len(sLST)-iPos_fisrtcomm -1) )
        ' again, to get first "," & second ","
        iPos_fisrtcomm = instr (1, sLST, ",")
        iPos_secondcomm = instr ((iPos_fisrtcomm +1), sLST, ",")
        ' make it's like "November 20, 1997"
        sLST = Left (sLST, iPos_secondcomm - 1)

        if ((date - datevalue (sLST)) < 5) then Response.Write " <img src=" & VRoot & "/images/new.gif>"
        ' end of function - to see if the doc is new, for example, in near 5 days

        Response.Write "</TR>"
        ' then, display nessesary properties one by one
        '  owner, ie, author
        Response.Write "<TR "<TD align=right valign=top width='30%'><b>Owner</b></TD>"
        Response.Write "<TD valign=top>"
        Response.Write "<a href='mailto:" & suminfo.Author & "'><u>" & suminfo.Author & "</u></TD>"
        '  subject
        Response.Write "<TR "<TD align=right valign=top><b>Subject</b></TD>"
        Response.Write "<TD valign=top>" & suminfo.Subject & "</TD>"
        '  title
        'Response.Write "<TR "<TD align=right valign=top><b>Title</b></TD>"
        'Response.Write "<TD valign=top>" & suminfo.Title  & "</TD>"
        '  comments
        Response.Write "<TR "<TD align=right valign=top><b>Comment</b></TD>"
        Response.Write "<TD valign=top>" & suminfo.Comments & "</TD>"
        Response.Write "</TD></TR>"
        '  last saved day
        Response.Write "<TR "<TD align=right valign=top><b>Last Saved Day</b></TD>"
        Response.Write "<TD valign=top>" & suminfo.LastSaveTime & "</TD>"
        Response.Write "</TD></TR>"
        
        '  word doc page number (only for word doc)
        if filetype = "doc" then
            Response.Write "<TR "<TD align=right valign=top><b>Word Page Number:</b></TD>"
            Response.Write "<TD valign=top>" & suminfo.PageCount & "</TD>"
            Response.Write "</TD></TR>"
        end if
        '  slides page number (only for ppt)
        if filetype = "ppt" then
            Response.Write "<TR "<TD align=right valign=top><b>Slides Page Number:</b></TD>"
            Response.Write "<TD valign=top>" & suminfo.Slides & "</TD>"
            Response.Write "</TD></TR>"
        end if
        end if        
    next

    Response.Write "</TABLE>"
    
    ' Release Resource - Kill the Objects
    set suminfo = Nothing
    set f1 = Nothing
    set fc = Nothing
    set f = Nothing
    set fs = Nothing
    
    
</SCRIPT>

</BODY>
</HTML>
=======================
-----------------------------------------------------------[交流]-[打印]-[发送]-[收藏]--
最新入库:
 
·10. 结束电话
·9 电话故障
·8. 分机、占线
·7. 打错电话
·6. 长途电话
·5. 转告消息
·4. 留 言
·3. 等候与回电
·2. 没找到人
·1. 打电话 接电话
相关内容:
 
·Checking Out 结帐
·Wake-up Call Service 唤醒服务
·Maintenance 维修服务
·Settling complaints 处理投诉
·Laundry Service 洗衣服务
·At the Reception Desk在接待处 2
·At the Reception Desk在接待处 1
·At the Entrance 在门口
·雅思必背的32个TOPIC
·BEC口试形式及评分标准
网友点评:
 
会员名称:
密码:匿名 ·注册·忘记密码?
评论内容:
(最多300个字符)
  查看评论
友情提醒:
 1.库中的资料大都来自互联网、网友上传、各类书籍,在录入的过程中难免会出现错误,恳请网
 友来信指正!
 2.如果网友在本库中未能找到所需要的材料,请登陆到我们的论坛《招考学习网》版块!
 3.考友想加入招考学习网的编辑部,请发信到XueXiWang#Gmail.com(#改为@)附带个人简历
 4.如需转载请注明出处及作者,谢谢合作!
 5.如果您有更好的建议或意见请EMAIL:XueXiWang#Gmail.com (#改为@)
 6.凡标题中有注有“[NO]”字样均不含答案且答案整理中.
 7.如本库中转载文章涉及版权等问题,请相关网站或作者在两周内发邮件通知(EMAIL:  XueXiWang#Gmail.com (#改为@))我们,我们接到通知后立即删除该文章及链接!
你问我答 更多>>