1.

Solve : Read a .txt file and delete line feed from the end of the file?

Answer»

Hello,

I have a requirement where my tool can take only those files having no line feed at the end of file.

Now the line feed char is char(10)

So how can I read that file and then find the end of file and DELETE that last line feed char.

cheersSounds like homework to me...


Just look into findstr and/or for and you might find something.yeah I tried using Findstr and tried FINDING Char(10), but it did'nt work.

So I wanted to ask about, How we can go to end of the file and then delete last linefeed just like pressing Backspace.

I tried using For with eof() and if reached end of file then char(08) which is a backspace char.

Please help me with this, as I have to do this in 500 txt files hence I want to use batch program.Whip something up with QBasic. If you haven't got it, here it is

http://www.geocities.com/TimesSquare/Arena/5451/qbasic/downloads/qbasic.zip

Open the file for reading as binary. Open another file for WRITING as binary. Read the file in byte by byte, WRITE them out one by one to the new file, when you get to the last byte, which would be 0A hex, just say no! Don't write it. Then close both files. It's that simple.


If this is your homework, you should be working it out for yourself. if it is your work, and you cannot do this, you got the job under false pretences, and why should we earn your pay for you?


Or am I being unfair?


Quote from: contrex on June 06, 2007, 04:07:43 AM

Or am I being unfair?

Not at all. That rule EXISTS for a reason.


Discussion

No Comment Found