Re: StreamWriter ?
- From: "Cowboy \(Gregory A. Beamer\)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Aug 2007 08:14:30 -0500
Write just writes, WriteLine() adds a \r\n, as Jerry mentioned. The final
line will be null, so you can iterate through the file like so.
string line;
while (null != (line = reader.ReadLine())
{
}
As far as, is it normal? As mentioned, the \r\n is normal. You will also
find that most ASCII files you get, from a variety of programs, use a null
line as an endpointer. Some even use char(0), but that is another story.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
************************************************
Think outside the box!
************************************************
"JerryWEC" <JerryWEC@xxxxxxxxxxxxxxxxx> wrote in message
news:eRz6ivF2HHA.4184@xxxxxxxxxxxxxxxxxxxxxxx
Hi all!
I'm creating a file using the following lines of code inside a property
set...
If Not File.Exists(value) Then
StreamWriter = File.CreateText(value)
StreamWriter.Close()
End If
When I look at this file it has a blank line (maybe a newline character).
I've been running like this for several months no problems. It just
bugged me that I had this extra line at the end of my log files.
Writing lines using...
StreamWriter.WriteLine("Some Text")
Now I'm trying to create an automatic clean up method to keep only the
last max lines. (In this case i'm using 1000 lines.) However, when I get
to 1001 lines written. I use...
Dim oldLines() as String = File.ReadAllLines(MyFileName)
And it's getting the extra blank line. Is this normal to have an extra
line at the end of your files using the above code???
TIA! Jerry
.
- References:
- StreamWriter ?
- From: JerryWEC
- StreamWriter ?
- Prev by Date: Re: Team Foundation Server Dual-Server Installation
- Next by Date: File.Delete / Recreating File bug
- Previous by thread: RE: StreamWriter ?
- Next by thread: RE: StreamWriter ?
- Index(es):
Relevant Pages
|