Read write to same file

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi All,

is it possible to read a file and write to the same file but the condition
is:
1. suppose there is a line "Today is Wednesday. A beautiful day" and I want
to change it to "Today is Thursday. A beautiful day"

Thanks,
Stephen
 
All ASCII files are fundamentally sequential files (unlike the mainframe
file systems). Therefore, if you want to replace one set of text with
another, you can either leave enough room in the 'line' for changes, and
change the entire line at a time (fixed width direct access) or you can read
the entire file into memory, replace the parts you want to replace, and
write the entire file back out (by far the more common approach).

The choice is yours.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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

Back
Top