Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error writing to a text file

Status
Not open for further replies.

JGresko

Programmer
Apr 24, 2002
86
0
0
US
I'm attempting to write to a text file but keep getting the same error "ERROR #62: Input past end of file" It's been so long since I've done this I know it has something to do with the cursor position in the file, but can't figure out how to fix it.


Here's the code I'm using....

Code:
Dim objFSO, objTextFile
Dim sRead, sReadLine, sReadAll
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("D:\InetPub\[URL unfurl="true"]wwwMemotech\Docs\HowToDemoFile.txt",[/URL] ForWriting, True)

' Write a line with a newline character.
objTextFile.WriteLine("testing")

objTextFile.Close

Thanks for any help you can give me.

Judy
 
The following code works for me (I use jscript not vb)

var addline = "add this line"
var StrPath = "path to textfile/file.txt";
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var objFile = objFSO.OpenTextFile(StrPath, 8, true);

objFile.WriteLine(addline)}

objFile.Close()
objFile = null;
objFSO = null;

note that I use the "ForAppending" parameter - 8
hope this is helpful.
ES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top