[Mono-aspnet-list] Problems writing a single new line. ASP.NET Ubuntu 11.04

Nathan Bridgewater nathan at integratedwebsystems.com
Tue Oct 18 17:23:56 EDT 2011


Another option is using a StringBuilder to construct your result and then
write that to a file. It seemed to work for me just the same on windows and
Linux (linux without the carriage return of course).

Try this:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2
{
    class Program
    {
        private static string _textBoxOne;
        private static string _textBoxTwo;
        private static string _textBoxThree;
        private static string _textBoxFour;
        private static string _textBoxFive;
        private static string _textBoxSix;
        private static string _textBoxSeven;
        private static string _textBoxEight;

        static void Main(string[] args)
        {
            var tableListThree = new List<string>();
            var getAndSet = new test() { PathOne = @"test.txt" };
            _textBoxOne = "_textBoxOne";
            _textBoxTwo = "_textBoxTwo";
            _textBoxThree = "_textBoxThree";
            _textBoxFour = "_textBoxFour";
            _textBoxFive = "_textBoxFive";
            _textBoxSix = "_textBoxSix";
            _textBoxSeven = "_textBoxSeven";
            _textBoxEight = "_textBoxEight";

            var builder = new StringBuilder();

            builder.AppendLine(string.Join("#", _textBoxOne, _textBoxTwo,
_textBoxThree, _textBoxFour, _textBoxFive, _textBoxSix, _textBoxSeven,
_textBoxEight));

//extra rows for sample.
            builder.AppendLine(string.Join("#", _textBoxOne, _textBoxTwo,
_textBoxThree, _textBoxFour, _textBoxFive, _textBoxSix, _textBoxSeven,
_textBoxEight));
            builder.AppendLine(string.Join("#", _textBoxOne, _textBoxTwo,
_textBoxThree, _textBoxFour, _textBoxFive, _textBoxSix, _textBoxSeven,
_textBoxEight));


//show output to console
            Console.Write(builder.ToString());
            Console.WriteLine();

//appending to file; uft8 is not required.
            File.AppendAllText(getAndSet.PathOne, builder.ToString(), new
UTF8Encoding(false,false));
        }
    }

    class test
    {
        public string PathOne { get; set; }
    }
}






On Tue, Oct 18, 2011 at 3:48 PM, Nathan Bridgewater <
nathan at integratedwebsystems.com> wrote:

> Consider using:
>
> System.Environment.NewLine as your newline string. It will automatically
> change between outputs (like unix, windows, html, etc).
>
> String.Format("{1}{0}{2}", line1, System.Environment.NewLine, line2);
>
> I imagine StringBuilder w/ AppendLine would work similarly.
>
> -Nathan
>
> On Mon, Oct 10, 2011 at 8:34 AM, cristian <c191288 at hotmail.com> wrote:
>
>> Is their no one who can help me out with this issue?
>>
>> Kind regards.
>>
>> --
>> View this message in context:
>> http://mono.1490590.n4.nabble.com/Problems-writing-a-single-new-line-ASP-NET-Ubuntu-11-04-tp3870006p3890255.html
>> Sent from the Mono - ASP.NET mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-aspnet-list mailing list
>> Mono-aspnet-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-aspnet-list
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20111018/a4ce8278/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux-runtime.png
Type: image/png
Size: 3728 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20111018/a4ce8278/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vim-newline.png
Type: image/png
Size: 3296 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20111018/a4ce8278/attachment-0001.png 


More information about the Mono-aspnet-list mailing list