Delete chars at the end of a text file
rochus
rochus at rochus.net
Sat Jan 13 02:42:16 PST 2007
Heinz wrote:
> Hi,
>
> Any ideas?
>
> Thanks in advance.
Hi Heinz!
The following did work under linux, don't know if it'll work on windows:
----[code]-----------------------
void
trimFile(char[] fileName, int count) {
// open file
auto file = cast(char[])std.file.read(fileName);
// cut of count characters
file = file[0 .. $-count];
// write file
std.file.write(fileName, file);
}
---------------------------------
you should place some exception-handling around each line, though.
Nicolai
More information about the Digitalmars-d-learn
mailing list