ASP FSO Display special folder implementation code (malformed directory name, UNC path) _ Application Tips

Source: Internet
Author: User
This is still a few individual can not show, turned the next MSDN seemingly did not see a better solution, to give up the continuation of research, there are know completely solve friends may wish to reply to say.
First attach bat to create a malformed directory, the following code copy is saved as A.bat:
Copy Code code as follows:

MD aux\\
MD com1\\
MD com2\\
MD prn\\
MD con\\
MD nul\\
MD dot...\\
MD Onedot. \\

Program code
Copy Code code as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<%
Option Explicit
Response.Charset = "UTF-8"
Session.CodePage = 65001
Session.Timeout = 1440
Server.ScriptTimeout = 9999
'***************************
' Name: Directory List class
' Author: Yi product
' Date: 2010-4-28
' URL: www.jb51.net
' Description: Directory list class, support for malformed directory names
'***************************
Class Fsocls
Private Fso
Public Fsoobj
Private Sub Class_Initialize
Set fso=createobject ("Scripting.FileSystemObject")
Set Fsoobj=fso
End Sub
Private Sub Class_Terminate
Set fso=nothing
Set fsoobj=nothing
End Sub
Function isfolderexists (FolderPath)
If FSO. FolderExists (FolderPath) Then
Isfolderexists = True
Else
Isfolderexists = False
End If
End Function
Function FolderItem (ByVal folderdir)
If Instr (Folderdir, ": \") >0 Then
Folderdir= "\\?\" &FolderDir& "\"
Else
Folderdir= "\\?\" &server.mappath (folderdir) & "\"
End If
If isfolderexists (folderdir) = False Then
Folderitem=false
Exit Function
End If
Dim Folderobj,folderlist,f,i
I=1
Set Folderobj=fso.getfolder (Folderdir)
Set folderlist=folderobj.subfolders
folderitem= "Total directory:" &FolderObj.SubFolders.Count& "folderitem=folderitem& "Total Files:" &FolderObj.Files.count& "
For each F in Folderlist
' Response.Write F.shortname
' Response.Write (InStr (1,f.shortname, "~", 1))
If isfolderexists (folderdir&f.name) = True Then Response.Write ("t<br>" & vbCrLf)
If (InStr (1,f.name, ".", 0) >0) Then
Response.Write ("T")
F.name=replace (F.name, ".", "-")
End If
folderitem=folderitem&i& "├─ folder →" &F.Name& "<br>" & vbCrLf
I=i+1
Next
Set folderlist=nothing
Set folderobj=nothing
End Function
End Class
%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Directory list classes support malformed directory names </title>
<body>
<%
Dim F:set F = new Fsocls
Response.Write F.folderitem ("/")
%>
</body>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.