?? bianli.asp
字號:
<%
function bianliFolder(currentPath)
'go through folders
path = server.mapPath(currentPath)
response.write("Current Folder is <b>" & path & "</b><br>")
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
'response.write(currentPath)
'response.write(InStrRev(currentPath,"/",-1,1))
'response.write(LEFT(currentPath,(LEN(currentPath)-InStrRev(currentPath,"/"))))
upperFolder = LEFT(currentPath,(InStrRev(currentPath,"/")-1))
IF upperFolder <> "" THEN
response.write("<image src='./images/toUpperFolder.gif'><a href='bianli.asp?rootPath=" & upperFolder & "'>")
response.write(upperFolder)
response.write("</a><br>")
END IF
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objSubFolders
'nowpath=path + "\" + objSubFolder.name
nowpath=objSubFolder.name
nextPath = currentPath & "/" & objSubFolder.name
'Response.Write nowpath
'Response.Write "<image src='./images/folderClose.gif'><a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
Response.Write "<image src='./images/folderClose.gif'><a href='bianli.asp?rootPath=" & nextPath & "'>" & nowpath & "</a>"
Response.Write "<p>"
'bianli(nowpath)'遞歸
next
Call bianliFile(currentPath)
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function bianliFile(currentPath)
'go through files
path = server.mapPath(currentPath)
'Response.Write("path is " & path & "<br>")
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
nowpath = path
'Response.Write("now path is " & nowpath & "<br>")
'Response.Write "<a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
set objFiles=objFolder.Files
for each objFile in objFiles
Response.Write "<br><image src='./images/plainFile.gif'>"
Response.Write objFile.name & "</a> "
Response.Write "<a href='?action=del&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./images/recyle.gif'>delit" & "</a> "
Response.Write "<a href='?action=display&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./images/edit.gif'>顯示文件內容" & "</a>"
next
Response.Write "<p>"
'bianli(nowpath)'遞歸
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function delit(fileType,path)
'remove a file
set fso=server.CreateObject("scripting.filesystemobject")
IF UCase(fileType) = "SINGLE" THEN
fso.DeleteFile(path)
END IF
IF UCase(fileType) = "MULTI" THEN
fso.DeleteFolder(path)
END IF
end function
%>
<%
function displayit(fileType,path)
'display a file
set fso=server.CreateObject("scripting.filesystemobject")
IF UCase(fileType) = "SINGLE" THEN
Set ts = fso.OpenTextFile(path)
s = ts.ReadAll
'Response.Write "File contents = " & s & ""
response.write s
ts.Close
END IF
IF UCase(fileType) = "MULTI" THEN
END IF
end function
function readItAll(path)
'read a file
Set objTStream = objFSO.OpenTextFile(path)
Do While Not objTStream.AtEndOfStream
'get the line number
intLineNum = objTStream.Line
'format and convert to a string
strLineNum = Right("00" & CStr(intLineNum), 3)
'get the text of the line from the file
strLineText = objTStream.ReadLine
Response.Write strLineNum & ": " & strLineText & vbCrLf
Loop
objTStream.Close
end function
Function writeTextFile(fileName,fileToWrite)
'write a file
Const ForReading = 1, ForWriting = 2
Dim fso, f, fsoFile
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(fileName)) Then
fso.DeleteFile(fileName)
End If
set fsoFile = fso.OpenTextFile(fileName,2,true)
fsoFile.writeline(fileToWrite)
fsoFile.close
set fsoFile = nothing
set fso = nothing
End Function
%>
<%
action = request.queryString("action")
IF action = "del" THEN
fileType = request.queryString("fileType")
filePath = request.queryString("filePath")
response.write(filePath)
Call delit(fileType,filePath)
'response.redirect("bianli.asp")
if err then
Response.Write "錯誤:"&Err.Description
response.end
else
Response.Write "成功!"
response.end
end if
END IF
IF action = "save" THEN
Dim db,fileToWriteType,fileContent,fileName
fileAddress = Request("fileAddress")
fileAddressNew = Request("fileAddressNew")
fileContent = Request("fileContent")
IF fileAddresNew = "" THEN
fileName = fileAddress
ELSE
fileName = fileAddressNew
END IF
Call writeTextFile(fileName,fileContent)
'Call funAlertMsg("操作成功!")
if err then
Response.Write "<br>錯誤:"&Err.Description
response.end
else
Response.Write "<br>成功!"
response.end
end if
END IF
%>
<%
IF action = "display" THEN
%>
<body>
<a href="javascript:history.back()"> GO BACK</a>
<form action="bianli.asp?action=save" method="post">
<textarea name="fileContent" cols=70 rows=30>
<%
on error resume next
fileType = request.queryString("fileType")
filePath = request.queryString("filePath")
Call displayit(fileType,filePath)
'response.redirect("bianli.asp")
%>
</textarea><br>
<input type="hidden" name="fileAddress" value="<%=filePath%>"><br>
<input type="submit" name="SAVE" value="SAVE">
</form><br>
<%
response.write(filePath)
%>
<%
if err then
Response.Write "<br>狀態:錯誤:"&Err.Description
response.end
else
Response.Write "<br>狀態:成功!"
response.end
end if
%>
</body>
<%
END IF
%>
<%
rootPath = request.queryString("rootPath")
'if not set the rootPath parameter then set it to current path
if rootPath = "" then rootPath = "."
Call bianliFolder(rootPath)
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -