Hello everyon
I am using filestream and streamwriter to download and save a xml page from the internet
The problem is that it has 3 bytes at the beginning of the file with garbage that i want to get rid off
so i use a simple code like this
FileStream* fs1 = new FileStream (input, FileMode::Open, FileAccess::ReadWrite)
StreamReader* sr1 = new StreamReader (fs1)
StreamWriter* sw1 = new StreamWriter(fs1)
char c = ' '
for (;;
c = sr1->Read()
if (c == '<'
sw1 ->Flush()
sw1 ->Close()
break
els
sw1 ->Write(' ')
Although the read is done correctly, the write does not appear to function
I don't know whether this code starts the write at the beggining of the file, is there a way to make sure of that
Then is a special function or character for deleting the unwanted characters that i find ?
Carl Daniel [VC++ MVP] - 05 Jun 2004 17:21 GMT
In order to remove (delete) bytes from a file, you need to re-write the
entire file content, less the part you want to delete, to a new file.
-cd
> Hello everyone
>
[quoted text clipped - 32 lines]
> function or character for deleting the unwanted characters that i
> find ?
Emmanouel - 06 Jun 2004 10:41 GMT
Thanks for the tip Car
I'll try your aproac
Thank yo
Emmanouel