需要客户端能通过相对路径在服务器上建立一个文件夹(XXX),并将本地文件夹(AAA)
传入服务(XXX)中。
我选择了FSO来进行制作。
首先判断服务器是否已存在此文件夹,如果已存在则提示不能建立。否则建立(XXX)
然后再将本地文件夹通过表单传入指定的目录(XXX)。
我用FSO在本地进行测试正常,(本地采用的是绝对路径)经判断能提示文件夹是否已经建立。
可我一换上HTTP://YY/XXX路径就显示错误,请问如何解决这个问题。
附上源码:
<%
Dim fso, f ,bg
Set fso=CreateObject("Scripting.FileSystemObject")
f = fso.FolderExists("http://localhost/new" & folder1)
if f=false then
Set bg = fso.CreateFolder("http://localhost/new"&folder1)
CreateFolderDemo = bg.Path
session("folder")=createfolderdemo
response.write "可以建立"
elseif f=true then
response.write "文件夹已经存在"
end if
%>
9 个解决方案
#1
seek
======================================================================
<%
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='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & upperFolder & "'>")
response.write(upperFolder)
response.write("</a><p>")
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='./system/systemimg/folderClose.gif'><a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
Response.Write "<image src='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & nextPath & "'>" & nowpath & "</a><br><p>"
'bianli(nowpath)'递归
next
Call bianliFile(currentPath)
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function bianliFile(currentPath)
'go through files
i = 1
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
response.write "<table width='100%'>"
for each objFile in objFiles
i = i + 1
if i mod 2 = 0 then
bgcolor="#eeeeee"
else
bgcolor="#ffffff"
end if
Response.Write "<tr bgcolor='"& bgcolor &"'><td><image src='./system/systemimg/plainFile.gif' width=20 height=20>"
Response.Write objFile.name & "</td>"
Response.Write "<td><a href='?action=del&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/recyle.gif' width=20 height=20>删除" & "</a></td>"
Response.Write "<td><a href='?action=display&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/edit.gif' width=20 height=20>编辑" & "</a></td></tr>"
next
response.write "</table>"
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=135 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)
%>
======================================================================
<%
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='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & upperFolder & "'>")
response.write(upperFolder)
response.write("</a><p>")
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='./system/systemimg/folderClose.gif'><a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
Response.Write "<image src='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & nextPath & "'>" & nowpath & "</a><br><p>"
'bianli(nowpath)'递归
next
Call bianliFile(currentPath)
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function bianliFile(currentPath)
'go through files
i = 1
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
response.write "<table width='100%'>"
for each objFile in objFiles
i = i + 1
if i mod 2 = 0 then
bgcolor="#eeeeee"
else
bgcolor="#ffffff"
end if
Response.Write "<tr bgcolor='"& bgcolor &"'><td><image src='./system/systemimg/plainFile.gif' width=20 height=20>"
Response.Write objFile.name & "</td>"
Response.Write "<td><a href='?action=del&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/recyle.gif' width=20 height=20>删除" & "</a></td>"
Response.Write "<td><a href='?action=display&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/edit.gif' width=20 height=20>编辑" & "</a></td></tr>"
next
response.write "</table>"
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=135 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)
%>
#2
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#3
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#4
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#5
应该是不可以的吧
= fso.CreateFolder("d:\\XXX\new"&folder1)
中的路径指的是在服务器上的路径.
= fso.CreateFolder("d:\\XXX\new"&folder1)
中的路径指的是在服务器上的路径.
#6
FSO对象如何关闭并释放。
#7
关于路径问题已经解决。
顺便请教一下:
一、为什么工作站能过网页在服务器建立文件夹时速度很慢。
有什么方法能让服务器快些吗?
(服务器配置很高:圆明100A)
二、FSO在使用完后如何关闭与释放。
顺便请教一下:
一、为什么工作站能过网页在服务器建立文件夹时速度很慢。
有什么方法能让服务器快些吗?
(服务器配置很高:圆明100A)
二、FSO在使用完后如何关闭与释放。
#8
5555555555555555555
#9
用 set fso_object=bothing 行不行呀。
#1
seek
======================================================================
<%
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='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & upperFolder & "'>")
response.write(upperFolder)
response.write("</a><p>")
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='./system/systemimg/folderClose.gif'><a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
Response.Write "<image src='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & nextPath & "'>" & nowpath & "</a><br><p>"
'bianli(nowpath)'递归
next
Call bianliFile(currentPath)
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function bianliFile(currentPath)
'go through files
i = 1
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
response.write "<table width='100%'>"
for each objFile in objFiles
i = i + 1
if i mod 2 = 0 then
bgcolor="#eeeeee"
else
bgcolor="#ffffff"
end if
Response.Write "<tr bgcolor='"& bgcolor &"'><td><image src='./system/systemimg/plainFile.gif' width=20 height=20>"
Response.Write objFile.name & "</td>"
Response.Write "<td><a href='?action=del&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/recyle.gif' width=20 height=20>删除" & "</a></td>"
Response.Write "<td><a href='?action=display&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/edit.gif' width=20 height=20>编辑" & "</a></td></tr>"
next
response.write "</table>"
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=135 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)
%>
======================================================================
<%
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='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & upperFolder & "'>")
response.write(upperFolder)
response.write("</a><p>")
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='./system/systemimg/folderClose.gif'><a href='del.asp?fileType=multi&filePath=" & nowpath & "'>" & nowpath & "</a>"
Response.Write "<image src='./system/systemimg/toUpperFolder.gif' width=20 height=20><a href='bianli.asp?rootPath=" & nextPath & "'>" & nowpath & "</a><br><p>"
'bianli(nowpath)'递归
next
Call bianliFile(currentPath)
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
function bianliFile(currentPath)
'go through files
i = 1
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
response.write "<table width='100%'>"
for each objFile in objFiles
i = i + 1
if i mod 2 = 0 then
bgcolor="#eeeeee"
else
bgcolor="#ffffff"
end if
Response.Write "<tr bgcolor='"& bgcolor &"'><td><image src='./system/systemimg/plainFile.gif' width=20 height=20>"
Response.Write objFile.name & "</td>"
Response.Write "<td><a href='?action=del&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/recyle.gif' width=20 height=20>删除" & "</a></td>"
Response.Write "<td><a href='?action=display&fileType=single&filePath=" & nowpath & "\" & objFile.name & "'>" & "<image border=0 src='./system/systemimg/edit.gif' width=20 height=20>编辑" & "</a></td></tr>"
next
response.write "</table>"
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=135 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)
%>
#2
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#3
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#4
代码没看懂,
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
我只想知道:
Set bg = fso.CreateFolder("d:\\XXX\new"&folder1)
可不可以变成:
Set bg = fso.CreateFolder("http://172.168.1.2/new"&folder1)
#5
应该是不可以的吧
= fso.CreateFolder("d:\\XXX\new"&folder1)
中的路径指的是在服务器上的路径.
= fso.CreateFolder("d:\\XXX\new"&folder1)
中的路径指的是在服务器上的路径.
#6
FSO对象如何关闭并释放。
#7
关于路径问题已经解决。
顺便请教一下:
一、为什么工作站能过网页在服务器建立文件夹时速度很慢。
有什么方法能让服务器快些吗?
(服务器配置很高:圆明100A)
二、FSO在使用完后如何关闭与释放。
顺便请教一下:
一、为什么工作站能过网页在服务器建立文件夹时速度很慢。
有什么方法能让服务器快些吗?
(服务器配置很高:圆明100A)
二、FSO在使用完后如何关闭与释放。
#8
5555555555555555555
#9
用 set fso_object=bothing 行不行呀。