Cannot appent to textfile

R

Rolf Rosenquist

With the following code I can create a new textfile if it does not exist,
but it seems impossible to me, to append data to an existing file.

Dim objOpenFile, objFSO, strPath
StrPath = Server.MapPath("../smslog.txt")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(StrPath) Then
Set objOpenFile = objFSO.OpenTextFile(StrPath, ForAppending)
Else
Set objOpenFile = objFSO.CreateTextFile(StrPath, True)
objOpenFile.WriteLine "KundNr;Namn;Datum;Tid" 'header
End if
..
..
..

Anyone see what I have done wrong?


/ Rolf
 
R

Ray Costanzo [MVP]

Are you receiving an error? Unexpected results? How do you know it's not
working? Give us details. Have you defined "ForAppending" anywhere?

Ray at home
 
R

Rolf Rosenquist

The browser shows a message that the page cannot be found. When I comment
out line 5 in the example everything else works, even when I have deleted
the text file and let line 7 create a new text file. It is only when I try
to append text to an existing text file that does not work.

Yes, I have defined "ForAppending" in the line 5.

/ Rolf
 
R

Rolf Rosenquist

Now it works.
Not with the "ForAppending" expression, but I found on a 4Guysfromrolla
webpage that this expression has a value of 8. So when I changed to 8 - it
all worked. :)

/ Rolf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top