Link to home
Start Free TrialLog in
Avatar of Hojoformo
Hojoformo

asked on

Permission denied Error with objFSO.OpenTextFile

I am trying to write out file from my classic asp program and keep getting a "permission deined error"  when I try to open the file for writting.  I am not sure if this is really a server permsisson problem or a bug in my code.  I do have permsission to create files so this error does not make any sense.

Line 354 - Set objTextFile = objFSO.OpenTextFile(strDirectory, ForAppending, True)

Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied
/Apogee/residential/account_history.asp, line 354

Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

My Code:

  Dim objFSO, objFSOText, objFolder, objFile
  Dim strDirectory, strFile
  Const ForAppending = 2
  set objFile = nothing
  set objFolder = nothing
  strFile = "Base64Data.txt"
  strDirectory=server.mapPath(strFile)
 
' Create the File System Object
  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.CreateTextFile(strDirectory)
   
  Set objTextFile = objFSO.OpenTextFile(strDirectory, ForAppending, True)

  Base64Data = oXML.xml
  Base64Data = Base64EncodeBinary(oXML.xml)

  objTextFile.WriteLine(Base64Data)
  objTextFile.Close
 
Avatar of kelvinwkw
kelvinwkw
Flag of Malaysia image

I've had this happen too. I think it has to do with some of the latest security patches for IIS/Windows. They often seem to change permissions on the folders/files, breaking some scripts. I change permissions and they work again.

Try changing the permissions to everyone (you said that works), then change them back to IUSR_machine. Sometimes that does it.

Also, if you're changing permissions in Windows Explorer, try changing them in both IIS and Windows Explorer. Sometimes I have to do that. It's a royal pain, but I haven't found a way around it.
ASKER CERTIFIED SOLUTION
Avatar of kelvinwkw
kelvinwkw
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial