473,796 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read directory list

I borrowed the below code from http://www.brainjar.com/asp/dirlist/ and
cannot get it to read my folder files. I don't get any errors or any output
to screen. I have the below folder permissions set to browse. Without using
the below page, I can browse the files. What did I miss?
thanks!

<%@LANGUAGE="VB SCRIPT" CODEPAGE="1252" %>
<% set fs = CreateObject("S cripting.FileSy stemObject")
set folder = fs.GetFolder("c :\inetpub\wwwro ot\bs\aa\")
%>
<% function MapURL(path)

dim rootPath, url

'Convert a physical file path to a URL for hypertext links.

rootPath = Server.MapPath( "/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")

end function %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitl ed Document</title>
</head>

<body>
<% sub ListFolderConte nts(path)

dim fs, folder, file, item, url

set fs = CreateObject("S cripting.FileSy stemObject")
set folder = fs.GetFolder(pa th)

'Display the target folder and info.

Response.Write( "<li><b>" & folder.Name & "</b- " _
& folder.Files.Co unt & " files, ")
if folder.SubFolde rs.Count 0 then
Response.Write( folder.SubFolde rs.Count & " directories, ")
end if
Response.Write( Round(folder.Si ze / 1024) & " KB total." _
& "</li>" & vbCrLf)

Response.Write( "<ul>" & vbCrLf)

'Display a list of sub folders.

for each item in folder.SubFolde rs
ListFolderConte nts(item.Path)
next

'Display a list of files.

for each item in folder.Files
url = MapURL(item.pat h)
Response.Write( "<li><a href=""" & url & """>" _
& item.Name & "</a- " _
& item.Size & " bytes, " _
& "last modified on " & item.DateLastMo dified & "." _
& "</li>" & vbCrLf)
next

Response.Write( "</ul>" & vbCrLf)

end sub %>
</body>
</html>
Oct 1 '06 #1
1 5564

shank wrote:
I borrowed the below code from http://www.brainjar.com/asp/dirlist/ and
cannot get it to read my folder files. I don't get any errors or any output
to screen. I have the below folder permissions set to browse. Without using
the below page, I can browse the files. What did I miss?
thanks!

<%@LANGUAGE="VB SCRIPT" CODEPAGE="1252" %>
<% set fs = CreateObject("S cripting.FileSy stemObject")
set folder = fs.GetFolder("c :\inetpub\wwwro ot\bs\aa\")
%>
>
dim fs, folder, file, item, url

set fs = CreateObject("S cripting.FileSy stemObject")
set folder = fs.GetFolder(pa th)

'Display the target folder and info.

Response.Write( "<li><b>" & folder.Name & "</b- " _
& folder.Files.Co unt & " files, ")
if folder.SubFolde rs.Count 0 then
Response.Write( folder.SubFolde rs.Count & " directories, ")
end if
Response.Write( Round(folder.Si ze / 1024) & " KB total." _
& "</li>" & vbCrLf)

Response.Write( "<ul>" & vbCrLf)

'Display a list of sub folders.

for each item in folder.SubFolde rs
ListFolderConte nts(item.Path)
next

'Display a list of files.

for each item in folder.Files
url = MapURL(item.pat h)
Response.Write( "<li><a href=""" & url & """>" _
& item.Name & "</a- " _
& item.Size & " bytes, " _
& "last modified on " & item.DateLastMo dified & "." _
& "</li>" & vbCrLf)
next

Response.Write( "</ul>" & vbCrLf)

end sub %>
</body>
</html>
You need to actually call the sub at some point. Replace the first two
lines of code with the following:
<%
ListFolderConte nts("c:\inetpub \wwwroot\bs\aa\ ")
%>

A
--
Mike Brind

Oct 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
4895
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
5
13305
by: Mitchell S. Honnert | last post by:
Is there a way, given the full path of a folder on a network, that one can programatically tell if you have Read access to that folder? I have an application where the user is able to select a number of search folders using the standard dialog control. There shouldn't be an issue with the search folder being on a local drive or a network drive. But if you don't have Read access to the folder, there's trouble. The user can see the...
2
5420
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do. I have created an ASP.NET web service that I have running on my development machine, and am trying to get it to run on my test server. Both machines are running Windows 2000 SP4, IIS 5, and the .NET 2.0 framework. When I attempt to access...
2
3694
by: Tiger | last post by:
I try to write a struct into a brut file but I can't write all var in this struct when I try to add user I have that : > testmachine:/usr/share/my_passwd# ./my_passwd -a users.db > Ajout d'une entrée dans la base : > > Username : test > Password : aze > Gecos : qsd
6
1979
by: citlaly | last post by:
Hi!! I'm a beginner in python and I'm trying to use the files from a "folder" as a list. What I want to do is read each one as a list, but just the name of the file, the data inside doesn't matter. How can I do it? I was trying using a list, but I don't know how "convert" the elements (files) to a list that I can read and manipulate... Thanks in advance for your help!! Citlaly....
5
2709
by: GenCode | last post by:
What is the best way to read a "readable" web directory... I know I can do this Client.DownloadFile("http://www.mydomain.com/readabledir/", c:\ \dir.txt"); But that gives me the html and all the other tags...all I want is a directory listing of all the *.gif in this dir and not all the html Now I know I can parse the html to get the gif file names...but I
10
11225
by: imfanee | last post by:
Hi ALL, I want to read list of all subdirectories in an array in perl. I know how to get a list of all files in a directory but it does not show subdirectories in that list. Can any help out on this issue. Thanks in advanced. Fanee G.
0
2750
by: svpriyan | last post by:
Hai Implemented a code that will read the 100s of files from a directory. Each time when i read a file , i will take that file and check the content of the file( i put them in to a List )and compare with the original List and if there is a different, then i update the array List with write function. this is what i need but i get error when i run the code, i coul dread only one file, later it stopped. it does not read the second file in...
0
3167
by: svpriyan | last post by:
hai, I could not understand how to debug the error i have now. target 1- read the files from directory // i able ot do this part 2- for each file for each file read the content & compare with the existing List & update the list // i able to do this part when i try to combine both parts , i got some following error
1
2450
by: DannyMc | last post by:
Hi all, I am in the progress of consolidating my 2 NIS databases into 1. My first step is to get the NIS record for particular department. I have software.csv which contain list of name in. software.csv: John Travolta Elthon John Sean King Ston Taylor Swif t Nicole cage
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.