While the code below works perfect in VB, it returns "Permission denied" when I run it through my web-server (page.asp).
- Windows XP
- Script enabled in the virtual folder
- No NTFS
- Even tried to put IUSR_..... in Administrators
I'm probably missing something basic. Have anyone got any ideas?
Set fso = CreateObject("Scripting.FileSystemObject")
Set textstream = fso.OpenTextFile("C:\Temp\test.txt", 2)
An Asp page is running in IIS as some user (usually Anonimous or Guest or User).
You have two choices:
The dangerous one is: run your asp as user with permission to write on server (really not encouraged!)
The safer one is: build a Com+ component, which may run even as Administrator, if you want, that has a method with those instructions. Via Asp page, you use createObject to instantiate that component, and use the method (yes, you can pass parameters, and even get a value back or change byref parameters) to read - write files....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The folder C:\Temp must be visible from the Virtual directory - if you are trying to write somewhere other than the virtual directory or one of the sub-folders, you are always going to get into trouble....
XP has a lot of protection switched ON by default (the opposite to what we're all used to).
Change the file that you're writing to, to something that can be seen by the virtual directory....see if that works. (I'll assume that you've already tried that, and it works.)
I don't think that IIS can write to anywhere other than a virtual directory. I have had to reverse map drives on a protected FTP server to get things writeable.
Good luck....and if you're not bald already, you will be by the time you figure IIS out