 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 26th, 2004, 11:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 26th, 2004, 12:48 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

July 26th, 2004, 12:48 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
|
|

August 5th, 2004, 12:31 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 6th, 2004, 10:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 6th, 2004, 11:42 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 7th, 2004, 12:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 9th, 2004, 11:40 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |