append file at the BEGINNING?
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-io' list.


Coffey, Dana

I want to open a text file and insert some text at the BEGINNING of the file
is opposed to appending beneath the existing text.

Can this be done?

dc

Reply to this message...
 
    
Peter Brunone

    Sure; just suck the whole file into a string, append on to the front, and
replace the contents back into the file.

Cheers,

Peter

|-----Original Message-----
|From: Coffey, Dana [mailto:Click here to reveal e-mail address]
|
|I want to open a text file and insert some text at the BEGINNING
|of the file
|is opposed to appending beneath the existing text.
|
|Can this be done?
|
|
|dc
|

Reply to this message...
 
    
David L. Penton
0) With System.IO...

1) Create a new file with a temp name.

2) Write the text

3) Loop the rest of the data onto the new file name

4) Delete old file

5) Rename new

OR

1) create new file with temp name

2) from a dos shell do a "copy tmp.txt+myfile.txt myfile.txt /Y"

David L. Penton, Microsoft MVP
JCPenney Technical Specialist / Lead
"Mathematics is music for the mind, and Music is Mathematics for the
Soul. - J.S. Bach"
Click here to reveal e-mail address

Do you have the VBScript Docs or SQL BOL installed? If not, why not?
VBScript Docs: http://www.davidpenton.com/vbscript
SQL BOL: http://www.davidpenton.com/sqlbol

-----Original Message-----
From: Coffey, Dana [mailto:Click here to reveal e-mail address]

I want to open a text file and insert some text at the BEGINNING of the file
is opposed to appending beneath the existing text.

Can this be done?

dc

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com