Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse a netowrk drive

Status
Not open for further replies.

zzfive03

Programmer
Jun 11, 2001
267
Good day.

Is there a VB method for browning a known network directory and being able to list the files in a web page. I am not intrested in modifying the files, just lisiting the file names.

Thanks in advance.
Mh
 
penny.gif
penny.gif
 
Thanks. That did appear to show me how to connect to my local server and look for a particular file name. But.. How would i search a known directory for "*.txt" and have it return me a list of all TXT files? What I am looking for is a search tool that allows wildcards.

Thanks!!
MH
 
<%@ Language=VBScript %>
<%
set FSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
' This sample with a fixed folder:
Set BrowseContents = FSO.GetFolder(Server.MapPath(&quot;.&quot;))
' (i'm sure you can make that flexible)
response.write &quot;<TABLE>&quot;
for each BrowsedFile in BrowseContents.Files
FExtBegPos = InStrRev(BrowsedFile.Name, &quot;.&quot;)
FExtTotal = len(BrowsedFile.Name)
FExt = Right(BrowsedFile.Name, FExtTotal - FExtBegPos)
' Filter on file extention
if FExt = &quot;TXT&quot; or FExt = &quot;txt&quot; then
Response.Write &quot;<tr><td>&quot; & BrowsedFile.Name
Response.Write &quot;</td></tr>&quot;
end if
next
response.write &quot;</table>&quot;
Set FSO = Nothing
Set BrowseContents = Nothing
%>
br
Gerard
 
Thanks Gerard, that is EXACTLY what i am looking for.

One last question. The folder i am trying to search is a mapped network drive. I tyred to modify the line:
Set BrowseContents = FSO.GetFolder(Server.MapPath(&quot;../../../../g&quot;))

I can get all the way up to my folder, but I cant seem to &quot;switch drives&quot; is there a special way to do this? (FYI 'G' is my mapped drive)

Thank you. Mark
 
define teh 'mapped drive' as a virtual directory with IIS (allow 'browse'), and use the name of that directory in the mappath. br
Gerard
 
OK;

I created a virtural directory in IIS 4.0 called 'PrintFiles' This directory is has a physical path of &quot;\\ticasna05fs\printfiles&quot;. I can see it fine in my IIS explorer, but my script does not see it, nor can i see it if I attmept to view it in Windows explorer. (I assuem you can not see virtural direcotrys this way). DO I need to do something special in my script to view and search my &quot;printfiles&quot; direcotry.

(sorry, I am new to virtural directories)
Mh, Thanks
 
\\ticasna05fs is the webserver ?
if not: the webpage uses this IUSR_<servername> so it could be an authorization problem.

if yes: you must put a &quot;/&quot; before the virtual directory name: Server.MapPath(&quot;/PrintFiles&quot;)




br
Gerard
 
STILL having problmes.. I setup the IUSR_<servername> I get a message:

Server object error 'ASP 0177 : 800a004c'

Server.CreateObject Failed

/mark.asp, line 4

The operation completed successfully.


 
I GOT IT WORKING!!! Thanks everyone for your help.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top