PDA

View Full Version : FSO Append to File


homeacademy
10-23-2003, 06:57 AM
I am trying to use the following ASP code to append the current date/time to a text file:
[quote]
<%
Dimfs,f,txtStream
ConstForAppending=8

Setfs=Server.CreateObject("Scripting.FileSystemObject")
If(fs.FileExists(Server.Mappath("/scheduled/now.txt"))=True)Then
FileName=Server.Mappath("/scheduled/now.txt")
Setf=fs.GetFile(FileName)
SettxtStream=f.OpenAsTextStream(ForAppending)
txtStream.WriteLine(now()&vbNewLine)

txtStream.Close
EndIf
%>
</CODE>
I get:
[quote]
MicrosoftVBScriptruntimeerror'800a0046'

Permissiondenied

/scheduled/schedule_test.asp,line9
</CODE>
What am I doing wrong? Thanks in advance for the assistance.

rory
11-04-2003, 04:11 AM
you need to set permissions for that folder if you havent already fixed this problem. Set them for read and write.

[b]quote:Originally posted by homeacademy

I am trying to use the following ASP code to append the current date/time to a text file:
[quote]
<%
Dimfs,f,txtStream
ConstForAppending=8

Setfs=Server.CreateObject("Scripting.FileSystemObject")
If(fs.FileExists(Server.Mappath("/scheduled/now.txt"))=True)Then
FileName=Server.Mappath("/scheduled/now.txt")
Setf=fs.GetFile(FileName)
SettxtStream=f.OpenAsTextStream(ForAppending)
txtStream.WriteLine(now()&vbNewLine)

txtStream.Close
EndIf
%>
</CODE>
I get:
[quote]
MicrosoftVBScriptruntimeerror'800a0046'

Permissiondenied

/scheduled/schedule_test.asp,line9
</CODE>
What am I doing wrong? Thanks in advance for the assistance.
</blockquote id="quote"></font id="quote">