|
-
Sep 12th, 2002, 02:37 PM
#1
Thread Starter
PowerPoster
Why Bad File Mode?
I am just trying to read the first line in a textfile, make some decisions, then re-write the file with the NEW string. But it tells me Bad File Mode on the line in red. Why?
Thanks
Code:
For i = 0 To UBound(arrTheRamFiles)
lblStatus.Caption = "Reading " & arrTheRamFiles(i)
Set objTextStream = objFso.OpenTextFile(arrTheRamFiles(i))
If Not objTextStream.AtEndOfStream Then
strWhatIsInTheRAMFile = objTextStream.ReadLine
' indicates no ?parameters at the end of the string
If LCase(Mid(strWhatIsInTheRAMFile, Len(strWhatIsInTheRAMFile), 1)) = "m" Then
strWhatIsInTheRAMFile = strWhatIsInTheRAMFile & strTheExtraStuff
Else
If InStr(1, LCase(strWhatIsInTheRAMFile), "author") = 0 Then
' add author=
strWhatIsInTheRAMFile = strWhatIsInTheRAMFile & "&author=""Coral Ridge Ministries"""
End If
End If
objTextStream.WriteLine strWhatIsInTheRAMFile
End If
Set objTextStream = Nothing
Next
-
Sep 12th, 2002, 03:21 PM
#2
PowerPoster
FSO modes include read, write, and append. They do NOT include "read and write at the same time" which is what you are attempting.
-
Sep 12th, 2002, 03:23 PM
#3
Thread Starter
PowerPoster
Originally posted by phinds
FSO modes include read, write, and append. They do NOT include "read and write at the same time" which is what you are attempting.
Thanks I got it! Why oh why don't they do that then?
-
Sep 12th, 2002, 03:27 PM
#4
PowerPoster
file streaming is moderately complicated because files are sequential access thingies and you can screw things up by attempting to write in the middle of a file. There's no way to open it up it you need to write more than what's there and there's no way to condense it if you write less than what's there.
You have to recreate the file, making your changes as you write the new one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|