list - Pure ASP hyperlink for all files in a folder -
i had project , couldn't find simple code anywhere.. hope helps someone! make sure set ntfs permissions iis app account on folder. use file:// files http:// direct , others relative links.
<% dim fs,fo,x set fs=server.createobject("scripting.filesystemobject") set fo=fs.getfolder("c:\path") each x in fo.files response.write("<a href=file:///" &x & ">" & x & "</a>" & "</br>") next set fo=nothing set fs=nothing %>
i found post , useful me. changed bit , wanted post here in case others find useful too. due difference in way have iis set locally , how set on server have un/comment lines when uploading server vs running locally. please bear in mind i'm front end guy , first time have written code please give feedback :)
<% 'dim previewurl string = "http://xxxxxx/"'preview dim previewurl string = ""'local 'dim site string = "xxxxx"'preview dim site string = ""'local dim currentdir string = httpcontext.current.request.physicalapplicationpath.tostring()+site+"\web" dim di new io.directoryinfo(currentdir) dim diar1 io.fileinfo() = di.getfiles("*.html")', io.searchoption.alldirectories)'change line if want sub directories dim dra io.fileinfo response.write("<h1>html pages</h1>") response.write("<ul>") 'list names of files in specified directory each dra in diar1 response.write("<li><a href="+previewurl+site+"/web/"+dra.name+" target=_blank>"+dra.name+"</a></li>") next response.write("</ul>") %>
Comments
Post a Comment