C# character counter when writing to new line

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-25T21:23:03Z Indexed on 2010/05/25 21:31 UTC
Read the original article Hit count: 149

Filed under:

Basically i'm trying to read a really big text file and when the charecters of the line reach X amount write to a new line, but i can't seem to get the charecter count to work. Any help is appricated!

using (FileStream fs = new FileStream(betaFilePath,FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    string betaFileLine = rdr.ReadLine();
                    int stringline = 0;
                    if (betaFileLine.Contains("þTEMP"))
                    {
                         //sb.AppendLine(@"C:\chawkster\workfiles\New Folder\GEL_ALL_PRODUCTS_CONCORD2.DAT");
                        string checkline = betaFileLine.Length.ToString();
                        foreach (string cl in checkline)
                        {
                            stringline++;

                            File.AppendAllText(@"C:\chawkster\workfiles\New Folder\GEL_ALL_PRODUCTS_CONCORD3.DAT", cl);
                            if(stringline == 1200)
                            {
                                File.AppendAllText(@"C:\chawkster\workfiles\New Folder\GEL_ALL_PRODUCTS_CONCORD3.DAT","\n");
                                stringline = 0;
                            }
                        }

                    }
                }

foreach (string cl in checkline) Error 1 Cannot convert type 'char' to 'string'

© Stack Overflow or respective owner

Related posts about c#