Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2004, 11:08 AM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Listing Folder Content

Hi Guys,

I am trying to list all files in a folder. Also, I would like for the user to just click on the listed file and it would open up.

Folder 1
  FileName 1 'Users click on FileName 1 and it open's right away
  FileName 2
  FileName 3

Thanks,
Judy

Reply With Quote
  #2 (permalink)  
Old July 26th, 2004, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Judy,

Code:
<%
  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Dim objFolder
  Dim strPath
  strPath = "C:\FooBar\Blah\" 
' or use \\Computername\sharename\ 
' if that folder is from a remote system.
  Set objFolder = objFSO.GetFolder(strPath)

  Dim objFile
  For Each objFile in objFolder.Files
     Response.Write "<a href='" strPath & objFile.Name & "'<BR>"
  Next
%>
Quote:
quote: 'Users click on FileName 1 and it open's right away
You can't open all types of files there unless the corresponding software that opens the file is installed in that system which tries to open that.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old July 26th, 2004, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

This might help...
http://www.asp101.com/samples/dir_list.asp

or

http://www.planet-source-code.com/vb...txtCodeId=6795


Reply With Quote
  #4 (permalink)  
Old August 5th, 2004, 12:31 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Guys,

I tried the code you posted and I get this error message:

Error Type:
Server.MapPath(), ASP 0174 (0x80004005)
An invalid '/' or '\' was found in the Path parameter for the MapPath method.
/trustee_site/trustee.asp, line 56


The code is as follows:

  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Dim objFolder
  Dim strPath

 ' strPath = "C:\inetpub\wwwroot\trustee_site\"
   strPath = "\\backdraft\administration\trustee_site\"
 ' if that folder is from a remote system.
 ' Set objFolder = objFSO.GetFolder(strPath)
  Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))

  Dim objFile

  For Each objFile in objFolder.Files
   ' Response.Write "<a href='" strPath & objFile.Name & "'</a><BR>"

     Response.Write strPath & objFile.Name & "<BR>"
  Next
%>

I can't seem to get the remote server path to be recognized if I take out the \\ before the server name. It tells me path not found. I am sure about the path being correct. Thanks for your help.

Judy

Reply With Quote
  #5 (permalink)  
Old August 6th, 2004, 10:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Judy,
I don't understand why you have to use Server.MapPath() there when you are giving the physicaly path reference. That too you are doing that to a remote system. Server.Mappath can be done to refer to path within the web server, not to other systems in your network. And server.mappath has to be used only when you specify virtual path of your web server.

Eg: your files are under "c:\testfolder", you asp files are hosted under c:\inetpub\wwwroot\ and you are particular about using server.mappath, then you should specify your strpath variable as "../../testfolder". This would list all the files in that folder. But instead you are using physical path referencing, that result in error. server.mappath understand only "/". For physical path reference you can only use "\". Also when you are trying to list files from remote system, you cannot use server.mappath() which you are actually missing in your code.

Hope this helps
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #6 (permalink)  
Old August 6th, 2004, 11:42 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Vijay,

I was trying different ways that is why I have server.mappath hoping that it could work. I also tried :

Set objFolder = objFSO.GetFolder(strPath)

which you had in your example with the "\\computername\sharename\" but was giving an error message path not found so that is why I tried the physical "C:\inetpub\wwwroot\trustee_site\" which works. The problem with this is the files on the remote server needs to be copied the the physical path "C:\inetpub\wwwroot\trustee_site\" for the program to work. I was hoping to not do this so users who has access to the remote server"\\backdraft\administration\trustee_site\"
can just add or delete files in that folder because they do not have access to the server I am running the asp program.

In a nutshell, I can't seem to make the \\computername\sharename\" work even if I use just the getfolder(strpath). It can not find the path. Am I missing something?

Thanks for your help.

Judy



Reply With Quote
  #7 (permalink)  
Old August 7th, 2004, 12:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is that remote system in the same domain as that of your web server? That should be something you are missing.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #8 (permalink)  
Old August 9th, 2004, 11:40 AM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Yes the server is in the same domain as the web server. This is why I thought that \\servername\sharename\ should work but instead it was giving me a file path not found error message.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing 8-10 and Listing 8-16. Asp.Net BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 February 6th, 2008 01:11 PM
Choosing content depending on content of other ele dsekar_nat XSLT 1 February 27th, 2006 05:58 AM
Listing of Directory Content ram_dwivedi Javascript 3 December 9th, 2005 05:13 AM
Making a folder virtual folder on button click in CsharpHelp C# 0 October 26th, 2005 05:57 AM
Folder listing and permissions Tom Perro Classic ASP Professional 1 February 23rd, 2004 10:59 AM



All times are GMT -4. The time now is 04:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.