update link list when file is added.

I am neededing to create a web page that is essentially a list of files as hyperlink. I was wondering is there a way that when a file is added to the particular folder it would automatically get linked on the page?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Would make more sense to store the file names in a db and build the page from the db
When a file is uploaded add a new entry to the db for it.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
You'll want to use the file system object, here's an example where it'll list all files in the current folder:

Dim strPathInfo, strPhysicalPath
  strPathInfo = Request.ServerVariables("PATH_INFO")
  strPhysicalPath = Server.MapPath(strPathInfo)

  Dim objFSO, objFile, objFileItem, objFolder, objFolderContents

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.GetFile(strPhysicalPath)
  Set objFolder = objFile.ParentFolder
  Set objFolderContents = objFolder.Files
  <TITLE>Display Directory</TITLE>
<TABLE cellpadding=5>
 <TR align=center>
  <td align=left>File Name</td>
  <td>File Size</td>
  <td>Last Modified</td>
  For Each objFileItem In objFolderContents
    Response.Write "<TR><TD align=left>"
    Response.Write objFileItem.Name 
    Response.Write "</TD><TD align=right>" 
    Response.Write objFileItem.Size 
    Response.Write "</TD><TD align=right>" 
    Response.Write objFileItem.DateLastModified 
    Response.Write "</TD></TR>"


Open in new window

Source:   http://p2p.wrox.com/classic-asp-professional/59514-asp-list-files-directory-dynamically.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlcannonAuthor Commented:
When I use the file system object i keep getting the following error:

Server.MapPath() error 'ASP 0171 : 80004005'

Missing Path

/technology/QCPlanIndex/QCPlanIndexStadeBeta.asp, line 7

The Path parameter must be specified for the MapPath method.

I am putting the network file path in here:

strPathInfo = Request.ServerVariables("\\Server\Folder")

Is this ocrrect?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
can you confirm which of the options below pertains on where the folder is that you want listed:

1) the folder is the same where the page is loading from
2) the folder is within another folder from within your site
3) the folder is OUTSIDE of where your site runs from

Your line of code where you set the strPathInfo is indeed incorrect. The Request.ServerVariables object can only contain certain preset values. You can have a look here to understand how it's used.

if the folder you want listed somewhere within the site, then it'll be easy to set up, just post the relative url of the folder. If it's outside the site, the you'll need to create a virtual folder within your site to point to it, which is only a bit more complex to set up.
jlcannonAuthor Commented:
the folder is outside where the site runs.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
ok, then follow the directions in the link below to set up what's called a virtual directory (or folder):


This is for IIS7, if you have a different version, let me know and I'll get you instructions for it. once you have the virtual directory set up (don't forget to set the permissions as well), change your code from

strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Open in new window


  strPathInfo = "/nameOfVirtualDirectory/"
  strPhysicalPath = Server.MapPath(strPathInfo)

Open in new window

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
>the folder is outside where the site runs.

If you just give permissions to the IIS_IUSER account, there is no need to make a virtual directory.  Once you do that, you can use fso to read the folders and / or files in that directory.   I do this for uploading files for instance.  When I upload a file, I move it outside the public www and use fso to save it and call it up later.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.