ASP > Server Info articles:
• ASP Session Timeout vs. IIS Connection Timeout
Read
• Determining the physical drive and directory of a file on the server
|
Return to index of articles
Determining the physical drive and directory of a file on the server
Category: ASP
Category: Server Info
Background
Sometimes it may be necessary for you to determine the drive and directory which a file is in when the file resides on a remote server which you do not have full access to (e.g. your ISP's server).
A good example is when you want to create a DSN-less connection to a Microsoft Access Database. You've uploaded your database. Do you really want to have to call your ISP and find out the physical path to your MDB file? Wouldn't it be easier to just figure it out yourself? The answer is yes. All you have to do is:
copy and paste the code below into a file
save the file as dirinfo.asp
upload the file to your web server
browse the file in your web browser (e.g. go to http://www.yourdomain.com/dirinfo.asp )
voila: the drive letter and full path of the file will be displayed. You can then use this info in your ADO connection string to connect to an Access database, or whatever else you need it for.
Code
TenVolt.com ASP File/directory info
<%'convert the virtual /data path the actual path
strPath = Server.MapPath("./")%>
This file is in the following drive/directory on the server:
<%=strPath%>
Example
This file is in the following drive/directory on the server:
\\10.0.0.106\tenvolt.com\public\classified
Related Tip
If you are doing this so that you can connect to an Access database, make sure the directory is writeable, otherwise you will not be able to modify or delete any records in your database. To make the appropriate directory writeable, you will most likely have to ask your ISP to do it for you.
7/1/2002
|