Truncate file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a text file. I want to delete the second part of file. How can I
delete the second half from file?

For example:
in file is:

Sentence 1.
Sentence 2.

and I want to delete from file "Sentence 2."

Thanks a lot

Lubos
 
I have a text file. I want to delete the second part of file. How can I
delete the second half from file?

For example:
in file is:

Sentence 1.
Sentence 2.

and I want to delete from file "Sentence 2."

You need to find the exact position in the file - in bytes, not
characters - and call FileStream.SetLength.
 
Back
Top