I tried SetEndof File and a few other things but i cannot figure out how to select, delete or replace the CHAR in a file on Disk. A small text file. I been seaching like crazy. I am finding everything else but this it seems.
Example 1
This is line line 1.
I want to delete the extra word line.
.......................................................
Example 2
This is line
2.
This is another line.
I want to make the number 2 move up so I only have 2 full lines.
Than CloseHandle.
Hope someone know how this is done
Thanks in advance.
PS
.......................................................
Example 3
This line 3
This is line 3
Can i insert the word is in line 3
Example 1
This is line line 1.
I want to delete the extra word line.
.......................................................
Example 2
This is line
2.
This is another line.
I want to make the number 2 move up so I only have 2 full lines.
Than CloseHandle.
Hope someone know how this is done
Thanks in advance.
PS
.......................................................
Example 3
This line 3
This is line 3
Can i insert the word is in line 3
You can only delete from end. Otherwise you have to read in almost all of file, and use moving operations to delete/replace what you want.
Yup,
You have to find the offset of the beginning and end of the word you want to clip. Read the whole file into a buffer if it's small enough starting at the end of the word then set the end of the file to the start of the word and append the buffer. Not much you can do besides that, everything else would be slower.
You have to find the offset of the beginning and end of the word you want to clip. Read the whole file into a buffer if it's small enough starting at the end of the word then set the end of the file to the start of the word and append the buffer. Not much you can do besides that, everything else would be slower.
I been to hell and back. I always thought this could be done until i tried it for many days.
donkey i read your post about mddle of a string and you said the ONLY way was to READ it in and slit the string.
Then to hear what you say comrade, it's THE END of my wild ideas.
At lease i finally learned my lesson about what is possible and what is not.
Posted on 2003-06-21 01:45:43 by cmax
donkey i read your post about mddle of a string and you said the ONLY way was to READ it in and slit the string.
Then to hear what you say comrade, it's THE END of my wild ideas.
At lease i finally learned my lesson about what is possible and what is not.
Posted on 2003-06-21 01:45:43 by cmax
I have one more question about this. I can't seem to stop and is planning to try to rig something up to get at lease half way there.
Ok, if i can do this one thing i will be on my way.
I can do Endof File but once i get there i want to back up one or two spaces than delete those one or two letters
Can this be done to a file on disk as i explained above.
If not than i really give up ...
Example:
This is Line 44
To be
This is Line 4
O know it may be simple if it was in my program but i am working with text files on disk and don't want to read them in unless i have to. If i can get this one out the way I worry about the rest latter.
Ok, if i can do this one thing i will be on my way.
I can do Endof File but once i get there i want to back up one or two spaces than delete those one or two letters
Can this be done to a file on disk as i explained above.
If not than i really give up ...
Example:
This is Line 44
To be
This is Line 4
O know it may be simple if it was in my program but i am working with text files on disk and don't want to read them in unless i have to. If i can get this one out the way I worry about the rest latter.
invoke SetFilePointer,-2,NULL,FILE_END
invoke SetEndOfFile,hFile
Will make your file two bytes shorter.
If your going to copy stuff after there's no need to set the end of the file, just begin writing at that file position.
invoke SetEndOfFile,hFile
Will make your file two bytes shorter.
If your going to copy stuff after there's no need to set the end of the file, just begin writing at that file position.
donkey, I asked the wrong question because I figured that out about a half hour ago when comrade idea hit me. Everything after the end can be deleted... So i made my own end with the way you did it but i did it from FILE_BEGIN.
My question should have been how do I delete those spaces or two letters.
Thanks again
Heck I just look at my clock and a half hour was only 10 minutes ago, I must be getting wore out.
My question should have been how do I delete those spaces or two letters.
Thanks again
Heck I just look at my clock and a half hour was only 10 minutes ago, I must be getting wore out.
You're going to have to do a copy for that one. Copy the file to a buffer if it's small enough then delete the original and create a new file starting at pos 2 or where-ever.
What do you think about Edit control Select and Clear. Can that be done by he handle or do the file have to be open.
Also how about keyboard delete like that.
Also how about keyboard delete like that.
If you have a handle the file is open. Doing it in an edit control is exactly the same thing but just adds a level of complexity to it. In the end it will load it into a buffer (the edit control) remove the parts that it doen't want and save it back to the file. This can be done without using the edit control much faster and more transparently.
Thank you for all the help donkey,
Now i think i still got a fighting chance to make things work.
Now i think i still got a fighting chance to make things work.