how to add a string to the beginning of a large binary file?

C

could ildg

I want to add a string such as "I love you" to the beginning of a binary file,
How to? and how to delete the string if I want to get the original file?

thanks.
 
P

Patrick Useldinger

could said:
I want to add a string such as "I love you" to the beginning of a binary file,
How to? and how to delete the string if I want to get the original file?

You shouldn't use Python to write a virus :)

-pu
 
C

could ildg

I'm not going to,
I just want to know how to manipulate a large file and insert or
delete some stuff in it.
 
F

Fredrik Lundh

could ildg said:
I just want to know how to manipulate a large file and insert or
delete some stuff in it.

you cannot insert or delete stuff in files in contemporary operating systems;
all you can do is to overwrite parts of the file, or add/remove stuff at the end
of the file.

to change a file in any other way, you have to create a new file (either by
loading the old file into memory, or by copying the contents of the old file
to a new temporary file, and removing/renaming the files when you're done)

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,228
Messages
2,571,157
Members
47,785
Latest member
deepusaini

Latest Threads

Top