createobject scripting.filesystemobject IIS 7 - vbscript code always trying to save file in C:\Windows\System32\inetsrv\ instead of web site folder

StackOverflow https://stackoverflow.com/questions/7668904

Pregunta

As per title

createobject scripting.filesystemobject IIS 7 - vbscript code is always trying to save file in C:\Windows\System32\inetsrv\ instead of web site folder

and I get a "permission denied" error of course

The file should be being saved in the web site folder.

Any help much appreciated.

edit: The vbscript is being called from a form in a website running under IIS7 on win 7 dev machine. I am not setting any path in this case but when I tried ".\" IIS also attempted to use the "inetsrv" path and not the web site root folder as I was expecting.

¿Fue útil?

Solución

Its trick to be sure without the presence of code in your question however I suspect that you are assuming that creating a file such as "ThisIsMyFile.txt" would create a file in the ASP application folder. It doesn't.

FileSystemObject knows nothing about IIS. It will use the application's current directory which defaults to he directory of the executable file used to start the process, which in the case of IIS is found in "C:\Windows\System32\inetsrv\".

What you need is this:-

Dim sFilePath : sFilePath = Server.MapPath("/") & "ThisIsMyFile.txt"

This creates a full path to a file that can be created in the web sites root folder.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top