ratsvbs
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 11/23/2011
-
Status: offline
|
Saving to file adds extra line
Wednesday, November 23, 2011 9:32 AM
( permalink)
Hi all, My first post here :-) I'm trying to open a file and do a find and replace on some contents and then save to a new file. The actual find and replace portion works fine except when saving to a new file I get an extra line added to the end of the file. Does anyone know why an extra line is added and how I can remove it? My code follows. Thanks Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("c:\testin.log", ForReading) strText = objFile.ReadAll strNewText = Replace(strText, "ddmmyy", "241111") Set objFile = objFSO.CreateTextFile("c:\testout.log") objFile.WriteLine strNewText objFile.Close
|
|
|
|
59cobalt
-
Total Posts
:
979
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: offline
|
Re:Saving to file adds extra line
Wednesday, November 23, 2011 9:55 AM
( permalink)
ratsvbs I'm trying to open a file and do a find and replace on some contents and then save to a new file. The actual find and replace portion works fine except when saving to a new file I get an extra line added to the end of the file. Does anyone know why an extra line is added and how I can remove it? [...]'... objFile.WriteLine strNewText[/code] Perhaps surprisingly, WriteLine() behaves exactly as documented: it writes the given string followed by a newline. Change WriteLine to Write, and your problem will disappear.
|
|
|
|
ratsvbs
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 11/23/2011
-
Status: offline
|
Re:Saving to file adds extra line
Wednesday, November 23, 2011 10:03 AM
( permalink)
Indeed  A fool I am. :-( Thanks for your help.
|
|
|
|
59cobalt
-
Total Posts
:
979
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: offline
|
Re:Saving to file adds extra line
Wednesday, November 23, 2011 10:21 AM
( permalink)
|
|
|
|