Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Nov 22, 1999

Finding Your Directory in IIS for the FileSystemObject

The FileSystemObject object (sic) in Active Server Pages (ASP) is very handy for reading, writing, and deleting files via server-side script. However, it isn't always easy to locate your files on your ISP's system. The FileSystemObject object requires a physical path to the file, not a virtual directory name. Fortunately, you can calculate the exact path using ASP's Request.ServerVariables and Server.MapMath methods. Once you determine where your virtual directory resides, you can pass the path to the FileSystemObject object's methods.

This script shows how to use Request.ServerVariables to discover the needed information--and a lot more--from Internet Information Server (IIS).

 
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Response.Write Request.ServerVariables("PATH_INFO") & "<BR>" 
Response.Write Request.ServerVariables("SCRIPT_NAME") & "<BR>"
Response.Write Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))
%>
<HR>
<%
for each Var in Request.ServerVariables
 Response.Write Var & ":" & Request(Var) & "<BR>"
next
%>
</BODY>
</HTML>
Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap