Re: StreamWriter ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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



.



Relevant Pages

  • Re: Is it possible
    ... The object browser can list all ... Dim FunctionName As String ... you could iterate through the passed ... Variant array to retrieve the individual elements (which now ...
    (comp.lang.basic.visual.misc)
  • JSP to MySQL Connector/J problem
    ... handshaking is good and I iterate threw the result set with the next ... I manually add another row from the mysql> prompt and I ... String formattedDate = fmt.format; ... ResultSetMetaData rsmd = null; ...
    (comp.programming)
  • Re: reversing a string - newbie question
    ... >> string in reverse direction. ... Since `strlen' has to iterate through the string to find its length, ... While the OP could not avoid to iterate through the string twice, ...
    (comp.lang.c)
  • Re: Record seperator
    ... into a string. ... It's always annoyed me a little that while it's easy to iterate over the ... it's more complicated to iterate over a file character ...
    (comp.lang.python)
  • Re: Properties for a custom class (not a collection)
    ... Public Property Get properties(key As String) As String ... Dim pc As clsPropetyCollection ... If you want to iterate the collection ... You write an iterator class or provide ...
    (comp.databases.ms-access)