views:

423

answers:

3

Hi, I'm writing to a file as shown below. I am ONE HUNDRED % SURE there are no line breaks in the variables being written to the file. However, at an arbitrary character count in every line printed to Notepad of applicable length, a line break is created. However, pressing delete at the end of the file (even holding delete) to get rid of any non-printing character such as a line break has no effect. Pressing backspace before the first character of any line affected by this deletes the last character on the previous line, but does get rid of the line break. Writing after the last character is immediately moved to the next line. I have tested on a new line, holding a character just to see if i can get past the point at which the word wrap begins. I can, but not where the c# has written to. I have tried TYPE KEYWORDS.LOG in the command, and it does not print the line breaks, so I do not (think) it will effect my reading the file by line later. But is this a glitch in Notepad? In C#? In IO.StreamWriter? In my code? (I don't think so?) Is it simply a property I am unaware of?

OBVIOUSLY, WORD WRAP IS NOT ON. BUT THANKS. . .

resizing the window does not wrap the text, or change the effects I have described at all.

// OPEN STREAM TO KEYWORDS.LOG
StreamWriter fileWrite = new StreamWriter("KEYWORDS.LOG");

for (int i=0;i<Referrals.Count();i++)
{
    // FIRST THE URL
    Console.Write("\n\n{0}\n-", Referrals[i].URL);

    // NOW TO THE FILE!
    fileWrite.Write("{0}@", Referrals[i].URL);


    var SortedKeys = from k in Referrals[i].Keywords.Keys orderby Referrals[i].Keywords[k] descending select k;
    foreach (string Phrase in SortedKeys)
    {
 // NOW TO THE CONSOLE
 Console.Write("\t({0}) {1}\n", Referrals[i].Keywords[Phrase], Phrase);

 // NOW TO THE FILE!
 fileWrite.Write("##{0}##{1}", Referrals[i].Keywords[Phrase], Phrase);
    }

    // LINE BREAK FOR FILE!
    fileWrite.WriteLine("");

}


    // CLOSE FILE STREAM
    fileWrite.Close();
A: 

Is it possible you you have "Word wrap" on in notepad? Sorry if this seems like an obvious question.

korona
Resize window to test
DrG
A: 

Errr... Doublecheck "Format" - "Word Wrap" in Notepad.

Anton Gogolev
+6  A: 

It probably isn't arbitrary, you just haven't seen the reason.

Have a look at http://stackoverflow.com/questions/908119/c-textwriter-inserting-line-break-every-1024-characters/908135

The max length is 1024.

Paste some example text if you can ;D

DrG