![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Mar 2005
Location: Washington
Posts: 89
Rep Power: 4
![]() |
About Adding Text to Beginning of File
I'm trying to add code in the beginning of approximately 3000 files. The codes are going to be the same on every file. However all of the 3000 files contain texts, therefore I need to create a program that loops through all the files and adds the codes just in the beginning of the file.
Do you know the most efficient way to approach this? |
|
|
|
|
|
#2 |
|
Sexy Programmer
|
Take the current text in the file and put it in a string, we'll call it strContents. Take the text you want to insert in the files and save it in another string, calling it strCode;
strNewContents = strCode + "\n" + strContents ^Do something like that and translate it to C++.
__________________
I would love to change the world, but they won't give me the source code! |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
For each file:
Open a temp file. Write the code to be added to the temp file. Open the old file. Read that and write the contents to the temp file. Close both files. Rename the temp file to the name of the old file. If you have failed to properly describe what you need, then toss out this answer, along with your description.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Mar 2005
Location: Washington
Posts: 89
Rep Power: 4
![]() |
thanks for the tips.
I'll put them to use. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding more info to a text file without erasing | crawforddavid2006 | C# | 2 | Apr 11th, 2007 2:10 PM |
| converting string to float | beginnerCCC | C | 22 | Oct 2nd, 2006 11:59 PM |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |