Hi,
I have coded a simple server side .asp page to write to a log text file. It is the example shown on page 409 of the Wrox book, 'Beginning Active Server pages 3.0'.
My problem is that when I try to write or append to a text file in my application root directory I get a 'permission denied' error. Even when I attempt to create a file I get a 'permission denied' error.
At first I thought it was simply a question of setting the IIS5 'Virtual Directory' settings with a tick against the 'write' option. I have done this but still get a 'permission denied' error.
The create text file command is generating the error:-
set objFileTextStream = objMyFileSystemObject.CtreateTextFile("C:\WEB\logfile.txt"
If anybody can suggest where I'm going wrong I'd be grateful. Below is the code I am trying to get working.
--------
<%
' ----------------------
' Variable Declaraitions
' ----------------------
Dim strPathInfo1 'Variables For Path
Dim objFile, objFSO 'Variables to define file to read
Dim objFileTextStream 'Define channel to read file object
Const ForAppending = 8 'Define Stream Append
' --------------
' Initialisation
' --------------
'Set Path & File From Default App Directory & Known File
strPathInfo1 = Request.ServerVariables "APPL_PHYSICAL_PATH"
& "logfile.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject"
'
' If Output File Exists
If objFSO.FileExists(strPathInfo1) Then
Set objFileTextStream = objFSO.OpenTextFile(strPathInfo1, ForAppending)
Else
Set objFileTextStream = objFSO.CreateTextFile(strPathInfo1)
End if
' ------------
' Main Process
' ------------
WriteToFile "Testing"
CloseLog
' --------------
' Sub Procedures
' --------------
' Write Line To File
Sub WriteToFile (strNewEntry)
Dim strLogEntry
strLogEntry = FormatDateTime(now) & " - " & strNewEntry
objFileTextStream.WriteLine strLogEntry
End Sub
' Close log File
Sub CloseLog()
objFileTextStream.Close
End Sub
I have coded a simple server side .asp page to write to a log text file. It is the example shown on page 409 of the Wrox book, 'Beginning Active Server pages 3.0'.
My problem is that when I try to write or append to a text file in my application root directory I get a 'permission denied' error. Even when I attempt to create a file I get a 'permission denied' error.
At first I thought it was simply a question of setting the IIS5 'Virtual Directory' settings with a tick against the 'write' option. I have done this but still get a 'permission denied' error.
The create text file command is generating the error:-
set objFileTextStream = objMyFileSystemObject.CtreateTextFile("C:\WEB\logfile.txt"
If anybody can suggest where I'm going wrong I'd be grateful. Below is the code I am trying to get working.
--------
<%
' ----------------------
' Variable Declaraitions
' ----------------------
Dim strPathInfo1 'Variables For Path
Dim objFile, objFSO 'Variables to define file to read
Dim objFileTextStream 'Define channel to read file object
Const ForAppending = 8 'Define Stream Append
' --------------
' Initialisation
' --------------
'Set Path & File From Default App Directory & Known File
strPathInfo1 = Request.ServerVariables "APPL_PHYSICAL_PATH"
Set objFSO = CreateObject("Scripting.FileSystemObject"
'
' If Output File Exists
If objFSO.FileExists(strPathInfo1) Then
Set objFileTextStream = objFSO.OpenTextFile(strPathInfo1, ForAppending)
Else
Set objFileTextStream = objFSO.CreateTextFile(strPathInfo1)
End if
' ------------
' Main Process
' ------------
WriteToFile "Testing"
CloseLog
' --------------
' Sub Procedures
' --------------
' Write Line To File
Sub WriteToFile (strNewEntry)
Dim strLogEntry
strLogEntry = FormatDateTime(now) & " - " & strNewEntry
objFileTextStream.WriteLine strLogEntry
End Sub
' Close log File
Sub CloseLog()
objFileTextStream.Close
End Sub