Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File I/O and text manipulation
Message
From
08/10/2005 06:23:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01057415
Message ID:
01057422
Views:
9
>In the old days we did something like this:
>
>
>
>FILE = fopen()
>while ( !FEOF(FILE) )
>{
>   ** Do something here reading or writing
>}
>
>
>
>This is the basic simple file manipulation we used in ANSI C and VFP.
>
>As far as I can tell C# has broken this down into stream readers, stream writers, file streams, file info objects, asynchronous readers and writers, blah blah blah. I don't want a reader and a separate writer. I want a reader/writer on the same existing file that I can read from and insert to.
>
>All I want to do is open a text file, search for certain strings, and insert text at those locations. Why is this such a pain? As near as I can tell I am going to need to open an existing file, read it into a new file with my changes, delete the old file, and rename the new one?
>
>Or perhaps spend another day reading and writing to a FileStream at the byte level?
>
>There must be an easier way to scan and edit a text file.

Eric,
FileStream covers that basic fopen() at a lowlevel.
If you directly work on same file you should be carefull about your position in file.
If your concern is only appending at the end then you might use:

StreamWriter sw = File.AppendText("filename.txt");

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform