asp file system object
        Posted  
        
            by sushant
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by sushant
        
        
        
        Published on 2010-05-12T09:22:44Z
        Indexed on 
            2010/05/12
            9:24 UTC
        
        
        Read the original article
        Hit count: 305
        
asp-classic
i am using this code to access files and folders.
 <%@ Language=VBScript %><%
option explicit
dim sRoot, sDir, sParent, objFSO, objFolder, objFile, objSubFolder, sSize
%>
<%  
sRoot = "D:Raghu"
sDir = Request("Dir")
sDir = sDir & "\"
Response.Write "
" & sDir & "
" & vbCRLFSet 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 ""
' 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 "Parent folder" & 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 "" & objSubFolder.Name & "" & 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 "" & objFile.Name & "" & sSize & "" & objFile.Type & "" & vbCRLF Next
Response.Write "" %>
it works fine. but when i try to access something on shred path like: "\cvrdd0110:share" it gives error. how to access these files?
© Stack Overflow or respective owner