Writing a script to the first line of a file without overwriting it?
by Roman Gwatyt · in Technical Issues · 10/06/2009 (4:10 pm) · 5 replies
Hey. I need to write a string to a new line at the top of a file without overwriting the file. It's a .cs file. Currently I can write to the string to a file, but it overwrites the contents of the file. This is using the openforwrite and writeline commands.
Here's an example of what I need; this is what the file contains already:
"//This is the file
function foo()
{"
I need it to write to the file, and come out like this:
"//New line here
//This is the file
function foo()
{"
Thanks.
Here's an example of what I need; this is what the file contains already:
"//This is the file
function foo()
{"
I need it to write to the file, and come out like this:
"//New line here
//This is the file
function foo()
{"
Thanks.
#2
10/06/2009 (9:54 pm)
I am working with someone who has a license, and yes, we are open to engine modifications if need be. However, I was hoping this wouldn't be something that would need it. Thanks.
#3
10/06/2009 (9:59 pm)
Konrad, I'm licensed and working with the engine code. He's helping with scripting for my project and only has access to the compiled engine binaries.
#4
10/06/2009 (10:02 pm)
I *think* we got this figured out via AIM though.
#5
@Roman: a simple solution might be reading the contents of the file, and rewriting the file with the new contents appended to the beginning of the old contents. Would that work for you?
10/07/2009 (5:56 am)
Thanks for clarifying that guys. @Roman: a simple solution might be reading the contents of the file, and rewriting the file with the new contents appended to the beginning of the old contents. Would that work for you?
Associate Konrad Kiss
Bitgap Games