Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

delete a character from a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Emmanouel - 05 Jun 2004 17:01 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.