问题
I am trying to create a virtual directory at my IIS7 and then use the virtual directory in the following code
sPath = "\CMapped\database\attendanceData\"
sDir = Server.MapPath(".") & sPath
response.write sDir
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set obj_FolderBase = fso.GetFolder(sDir)
response.end
But I got the following error:
What I have done is as follow:
I created the virtual directory and set the path to C:\ Drive. My localhost is at D:\ drive. I have also set Connect as and entered my log in and password. I am the administrator of the PC. Everything authorized.
Then I go to C: and set it as a shared folder
I went back to IIS and click on the virtual directory -> Managed Virtual Directory -> Browse. I successfully connect to the directory
Now when I try the code, everything failed. The GetFolder function doesn't seems to recognize the path. The web server is at D: and the file server is at C: Please help.
sPath = "\CMapped\database\attendanceData\"
sDir = Server.MapPath(".") & sPath
response.write sDir
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set obj_FolderBase = fso.GetFolder(sDir)
response.end
The directory structure
回答1:
What you are trying would work in an href
or src
attribute, or with
<!--#include virtual="\CMapped\database\attendanceData\yourfile.asp"-->
.
With server.mappath
though I think you need to use the physical directory structure on the machine. As your virtual directory is on a different drive I suggest you go with
sDir = "C:\full_physical_path_to\database\attendanceData\"
来源:https://stackoverflow.com/questions/50500456/create-virtual-directory-iis7-to-be-use-in-getfolder-in-server-createobjectscr