Create Virtual Directory IIS7 to be use in GetFolder in Server.CreateObject(“Scripting.FileSystemObject”)

☆樱花仙子☆ 提交于 2019-12-11 14:23:23

问题


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:

  1. 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.

  2. Then I go to C: and set it as a shared folder

  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!