As far as I know, you cannot delete a line from a text file without writing the file again, unless it's the last line, in which case you could read to the point just before the first line, and TRUNCate the file there.
Can you please tell me more detail about your statement:
without writing the file again, unless it's the last line, in which case you could read to the point just before the first line, and TRUNCate the file there.
I have to read a textfile and import it into Navision.
e.g.
95004969;10000;1100128;818,00;;0;;;;
95004969;30000;1300176;16,00;;0;;;;
95004969;20000;1230138;79,00;;0;;;;
95004969;50000;1800367;124,00;;0;;;
After read the first line, I want to delete the Line and then save it. The problem is how to delete....
As I mentioned earlier, you cannot easily delete the first line in a file. In your case, I think you will need to
a. Read the first line;
b. Create a temporary file;
c. Write the second and following lines to the temporary file;
d. Delete the original file;
e. Rename the temporary file, so that it has the same name as the original file.
Are you sure it won't be possible to achieve what you want to do differently? Why do you want to delete the lines one by one, and do you really need to start with the first one?
Comments
Jan Hoek
Product Developer
Mprise Products B.V.
Can you please tell me more detail about your statement:
I have to read a textfile and import it into Navision.
e.g.
95004969;10000;1100128;818,00;;0;;;;
95004969;30000;1300176;16,00;;0;;;;
95004969;20000;1230138;79,00;;0;;;;
95004969;50000;1800367;124,00;;0;;;
After read the first line, I want to delete the Line and then save it. The problem is how to delete....
a. Read the first line;
b. Create a temporary file;
c. Write the second and following lines to the temporary file;
d. Delete the original file;
e. Rename the temporary file, so that it has the same name as the original file.
Are you sure it won't be possible to achieve what you want to do differently? Why do you want to delete the lines one by one, and do you really need to start with the first one?
Jan Hoek
Product Developer
Mprise Products B.V.