delete a character from a file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 ?
 
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
 
Back
Top