0
我正在使用此代碼瀏覽遠程計算機上可用的文件夾。從asp文件傳遞文件夾路徑
<%@ Language=VBScript %><%
option explicit
dim sRoot, sDir, sParent, objFSO, objFolder, objFile, objSubFolder, sSize
%>
<META content="Microsoft Visual Studio 6.0" name=GENERATOR><!-- Author: Adrian Forbes -->
<%
sRoot = "\\iflblw-bpd-12\Vercon_IP-BPD-01\SOFT"
sDir = Request("Dir")
sDir = sDir & "\"
Response.Write "<h1>" & sDir & "</h1>" & vbCRLF
Set objFSO = CreateObject("Scripting.FileSystemObject")
on error resume next
Set objFolder = objFSO.GetFolder(sRoot & sDir)
if err.number <> 0 then
Response.Write "Could not open folder"
Response.End
end if
on error goto 0
sParent = objFSO.GetParentFolderName(objFolder.Path)
' Remove the contents of sRoot from the front. This gives us the parent
' path relative to the root folder
' eg. if parent folder is "c:webfilessubfolder1subfolder2" then we just want "subfolder1subfolder2"
sParent = mid(sParent, len(sRoot) + 1)
Response.Write "<table border=""1"">"
' Give a link to the parent folder. This is just a link to this page only pssing in
' the new folder as a parameter
Response.Write "<tr><td colspan=3><a href=""browse.asp?dir=" & Server.URLEncode(sParent) & """>Parent folder</a></td></tr>" & vbCRLF
' Now we want to loop through the subfolders in this folder
For Each objSubFolder In objFolder.SubFolders
' And provide a link to them
Response.Write "<tr><td colspan=3><a href=""browse.asp?dir=" & Server.URLEncode(sDir & objSubFolder.Name) & """>" & objSubFolder.Name & "</a></td></tr>" & vbCRLF
Next
' Now we want to loop through the files in this folder
'For Each objFile In objFolder.Files
' if Clng(objFile.Size) < 1024 then
' sSize = objFile.Size & " bytes"
' else
' sSize = Clng(objFile.Size/1024) & " KB"
'end if
' And provide a link to view them. This is a link to show.asp passing in the directory and the file
' as parameters
' Response.Write "<tr><td><a href=""show.asp?file=" & server.URLEncode(objFile.Name) & "&dir=" & server.URLEncode (sDir) & """>" & objFile.Name & "</a></td><td>" & sSize & "</td><td>" & objFile.Type & "</td></tr>" & vbCRLF
'Next
Response.Write "</table>"
%>
我想將文件夾路徑傳遞到另一頁上的窗體。其實,在填寫表格時,應該調用這個頁面。你如何通過這條路?
例如,我需要的是當用戶想要選擇一個文件夾時,他點擊了一個調用此頁面的按鈕。在選擇文件夾時,文件夾的路徑應該返回到表單。
任何幫助真的很感激。
可能要工作在格式化你的代碼中有,芽。點擊編輯,突出顯示您的代碼,然後單擊文本框上面的全部爲1和0的按鈕。 – rossipedia 2010-05-17 09:22:06
感謝您的講解。但我不知道如何突出評論 – sushant 2010-05-17 09:29:08
點擊小橘子?在「您的答案」發帖框右上角的框。它會有很多指導讓你開始格式化你的貼子:D – RandyMorris 2010-05-17 10:06:51