Hello, I have a problem not far from the one quoted above, namely retrieving data from a text file containing the log file, and then convert each value and come out the graphic representation. And so far my code is not working as it should, and I just can not seem to get them all as it should, and suddenly I have need your aide.Thx advance.

the logfile is located in a folder in my computer, turning and with the low end of code if I try to read all the values ​​of the text, but without success, because the values ​​are read, but not all.

private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String Choosen_File = "";
            OpenFD.InitialDirectory = "Y:";
            OpenFD.Title = " Open a LoggFile";
            OpenFD.FileName = "";
            OpenFD.Filter = "Textdokument|*.txt|World Documents|*.doc|Microsoft Excel-Arbeitsblatt|*.";
            //"TextFiles|*.txt|Word Documents|*.doc";
            if (OpenFD.ShowDialog() != DialogResult.Cancel)
            {

                Choosen_File = OpenFD.FileName;
                richTextBox1.LoadFile(Choosen_File, RichTextBoxStreamType.PlainText);

            }

            else
            {
                MessageBox.Show("Cancel Button Clicked");

            }


        }
private void button2_Click(object sender, EventArgs e)
        {
            // Read in a file line-by-line, and store it all in a List.
             
                using (StreamReader reader = new StreamReader(OpenFD.FileName))
            {  
                  
                string line = null ;
               
                String[] StArr = null;
                char [] _Delimiters_char = {' ', ';', ','};
                int count = 0;
                

                  
                while ((line = reader.ReadLine()) != null)
                {   
                    StArr =line.Split(_Delimiters_char);
                   
                    for (count = 0; count <= StArr.Length - 1; count++)
                    {
                        MessageBox.Show(StArr[count]);
                        
                    }
                        
                }
           }

Example of said file


IBBPARA d RA d ƒ}ÅÄ
ô ¼ 2 2 n ä|Ôþ & P ‚}ÅÄ
ô ¼ 2 2 n ä|Ôþ & P )ÅÄ
ô ¼ 2 2 n ä|Ôþ & P ®ÅÄ
ô ¼ 2 2 n ä|Ôþ & P ‚}ÅÄ
ô ¼ 2 2 n ä|Ôþ & P ƒ}ÅÄ
ô ¼ 2 2 n ä|Ôþ & P ƒ

Recommended Answers

Would you mind writing the question in words? So we can all understand what are you trying to do?

Jump to Post

put this code in your program

private void button4_Click(object sender, EventArgs e)
{
try
            {

                //Creates a file with read-write access that allows others to read
               System.IO.FileStream wFile;
  wFile = new FileStream(OpenFD.FileName, FileMode.Open, FileAccess.Read);
            string filePath = OpenFD.FileName;
                        //Liest einen Byteblock aus dem Stream und schreibt die …
Jump to Post

this program is converting each byte array element at a time into hexadecimal and then into integer as far as your question is concerned you should check this condition when you read the file and if you current question is answered please mark this thread solved and start new thread …

Jump to Post

May be you are right please explain :)

Jump to Post

Check this link and this link... both of this links contain source code for the log …

Jump to Post

All 44 Replies

can somebody help me please

Can you tell me what is you encoding scheme?

Change you button2_click event in

private void button2_Click(object sender, EventArgs e)
        {
       String[] StArr = null;
                char [] _Delimiters_char = {' ', ';', ','};
                int count = 0;
    foreach(String line in richTextBox1.Lines)
                {   
                    StArr =line.Split(_Delimiters_char);
                   
                    for (count = 0; count < StArr.Length; count++)
                    {
                        MessageBox.Show(StArr[count]);                        
                    }                        
                }        
        }

Hey the way i want to do is to read those character(in a long textfila) and later convert it and make a graphic.but when i try with your code,it never run

Can you please give you complete code so that i could figure out what's the problem?

it look something like that

/*Created by Rminator 
 * Date 16/05/2011
 * Time: 10:17
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.VisualBasic;







namespace Auswertesoftware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //dplot.DPlot_FindDPLOTLIB();
            //dplot.DPlot_SetErrorMethod((2)); 
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {

        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String Choosen_File = "";
            OpenFD.InitialDirectory = "C:";
            OpenFD.Title = " Open a LoggFile";
            OpenFD.FileName = "";
            OpenFD.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
            //"Textdokument|*.txt|World Documents|*.doc|Microsoft Excel-Arbeitsblatt|*.|Textdokument|*.log|";
            //"TextFiles|*.txt|Word Documents|*.doc";
            if (OpenFD.ShowDialog() != DialogResult.Cancel)
            {

                Choosen_File = OpenFD.FileName;
                richTextBox1.LoadFile(Choosen_File, RichTextBoxStreamType.PlainText);

            }

            else
            {
                MessageBox.Show("Cancel Button Clicked");

            }


        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String Save_File = "";
            SaveFD.InitialDirectory = ":Y";//We're setting the default folder to be C
            SaveFD.Title = "Save  a  LogFile";
            SaveFD.FileName = "";
            SaveFD.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
            //"Textdokument|*.txt|World Documents|*.doc|Microsoft Excel-Arbeitsblatt|*.";// we´re Setting the Type of File we´re abble to be Open

            if (SaveFD.ShowDialog() != DialogResult.Cancel)
            {
                Save_File = SaveFD.FileName;
                richTextBox1.SaveFile(Save_File, RichTextBoxStreamType.PlainText);//The RichTextBox can open plain text files as well as Word documents

            }

            else
            {
                MessageBox.Show("Cancel Button Clicked");

            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            string myStr;
            using (FileStream fs = File.OpenRead(OpenFD.FileName))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                myStr = Encoding.Default.GetString(buffer);
                FileInfo fi2 = new FileInfo(SaveFD.FileName);
                if (fi2.Exists)
                {
                    StreamWriter sw = new StreamWriter(fi2.FullName, true, Encoding.Default);
                    sw.Write(myStr);
                    sw.Close();

                }

            }




        }
        private void button2_Click(object sender, EventArgs e)
        {
            // Read in a file line-by-line, and store it all in a List.

            String[] StArr = null; char[] _Delimiters_char = { ' ', ';', ',' }; 
            int count = 0; 
            foreach (String line in richTextBox1.Lines) 
            { StArr = line.Split(_Delimiters_char);
            for (count = 0; count < StArr.Length; count++)
            { listBox1.Items.Add(StArr[count]); }//MessageBox.Show(StArr[count]); } 
            }


                using (StreamReader reader = new StreamReader(OpenFD.FileName))//       Instance von der Klasse Streamreader,Zeillenweises lesen eine Datei
            {  

                string line = null ;

                //String[] StArr = null;
                //char [] _Delimiters_char = {';',' '};
                //int count = 0;

                //StArr = line.Split(_Delimiters_char);
                //while (VisibleString.Contains(" ")) { VisibleString.Replac(" ", ""); }


                do
                {
                    line = reader.ReadLine();
                    //while (line.Contains(" ")) { line.Replace(" ", ""); }



                    if (line.Contains(" "))
                    {

                        line = line.Replace(" ", "");

                    }

                    StArr = line.Split(_Delimiters_char);

                    for (count = 0; count <= StArr.Length - 1; count++)
                    {

                        listBox1.Items.Add(StArr[count]);
                        //count++;
                    }

                    count++;




                }
                while ((line = reader.ReadLine()) != null );
           } 




            }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int cx = ClientSize.Width;
            int cy = ClientSize.Height;
            Graphics g = e.Graphics;
            PointF[] aptf = new PointF[cx];
            for (int i = 0; i < cx; i++)
            {
                aptf[i].X = i;
                aptf[i].Y = cy / 2 * (1 - (float)Math.Sin(i * 2 * Math.PI / (cx - 1)));
            }
            g.DrawLines(new Pen(Color.BlueViolet), aptf);
            /*My_Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            My_Pen.Color = System.Drawing.Color.RoyalBlue;
            My_Pen.Width = 4;*/

        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

It is working fine here Can you tell me the exception or the error you are encountering

Daten have been send from an energy regulator in Logfile, and I want to read the File characters after characters, then i can save them in an array, and convert them, and make a graphic of the regulation according to temperature and the time .But my code so far do not work, it does not read allcharacter of the characters Logfile, let alone one letter as it should

oh it means to read the characters of file not strings?

Yes every character,one after the other,save it and late make a graphic of it

ok then try adding this code in you button2_click

private void button2_Click(object sender, EventArgs e)
        {
            String[] StArr = null; char[] _Delimiters_char = { ' ', ';', ',' };
            int count = 0;
            foreach (String line in richTextBox1.Lines)
            {
                StArr = line.Split(_Delimiters_char);
                for (count = 0; count < StArr.Length; count++)
                {
                    for (int j = 0; j < StArr[count].Length; j++)
                       listBox1.Items.Add(StArr[count][j]);                   
                }
            }
        }

it is good,but it never read every character,try it wit this Logfile,you will what i am talking about thx in advance


IBBPARa h 0002 Rah 00600Óý:
ô ¼ 2 f n äˆú Ôþ h 0060 ÿ:
ô ¼ 2 f n äˆú d h 0060ÿÁÿ:
ô ¼ 2 f n äˆú d þ i 0060 án;
ô ¼ 2 f n äˆú Ôþ i 0060ÿÓp;
ô ¼ 2 f n äˆú d i 0060 Óp;
ô ¼ 2 f n äˆú d i 0060 r;
ô ¼ 2 f n äˆú Ôþ i 0060 Ýs;
ô ¼ 2 f n äˆú Ôþ i 0060 ¤u;
ô ¼ 2 f n äˆú Ôþ i 0060 v;
ô ¼ 2 f n äˆú Ôþ * i 0060 zw;
ô ¼ 2 f n äˆú Ÿ† Ÿ†d i 0060 –x;
ô ¼ 2 f n äˆú Ôþ i 0060ÿˆz;
ô ¼ 2 f n äˆú d i 0060 ˆz;
ô ¼ 2 f n äˆú d i 0060 =|;
ô ¼ 2 f n äˆú Ôþ i 0060ÿ/~;
ô ¼ 2 f n äˆú d i 0060 /~;
ô ¼ 2 f n äˆú d i 0060 ³€;
ô ¼ 2 f n äˆú Ôþ i
0060 r‚;
ô ¼ 2 f n äˆú Ôþ i
0060ÿc„;
ô ¼ 2 f n äˆú d i
0060 c„;
ô ¼ 2 f n äˆú d ^F i
0060 ÓL
ô ¼ 2 f n äˆú Ôþ * i
0060 ¨L
ô ¼ 2 f n äˆú d i
0060 L
ô ¼ 2 f n äˆú d i
0060ÿÅL
ô ¼ 2 f n äˆú d i 0060 ñL
ô ¼ 2 f n äˆú Ôþ i 0060 'L
ô ¼ 2 f n äˆú d i 0060ÿãL
ô ¼ 2 f n äˆú d i 0060 'L
þ ¼ 2 f n äˆú Ôþ i 0060 'L
þ ¼ 2 f n äˆú Ôþ i 0060 T(L
þ ¼ 2 f n äˆú i 0060 g)L
þ ¼ 2 f n äˆú

I understood but these characters are in some coding scheme try decoding them

allright

yes i have allready decode it,and now i am suppose to represente it in a 2D graphic,in my X Axis(Date and hour) in my Y axis temperature,and all the value of Flr1;Flr2;Flr3;Flr4;Flr5;Flr6;Flr7;Flr8;Flr9;Flr10;Aus1;Aus2;Aus3;Aus4;Aus5;Aus6;Aus7;Aus8;Spg1;Spg2;Spg3 are suppos to be represented

Zeitpunkt; Flr1; Flr2; Flr3; Flr4; Flr5; Flr6; Flr7; Flr8; Flr9; Flr10;Aus1;Aus2;Aus3;Aus4;Aus5;Aus6;Aus7;Aus8;Spg1;Spg2;Spg3;
10.05.2011 17:04:20; 38,9; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:30; 38,8; 21,8; 61,9; 10,4; 0,0; 24,7; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:40; 38,9; 21,8; 61,9; 10,5; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7;100; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:50; 38,8; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:00; 38,9; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:10; 38,9; 21,9; 61,9; 10,5; 0,0; 24,7; 0,0; 0,0; -45,6; 8,7;100; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:20; 38,9; 21,8; 61,9; 10,5; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:30; 39,0; 21,8; 61,9; 10,6; 0,0; 24,6; 0,0; 0,0; -45,5; 8,7; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;

May somebody give an answer please....

Seems you can translate a binary file into a textfile, so what is the problem of extracting date,time and value strings out of it? Please be VERY clear in your answer.
I live in Belgium, next to your country so I also don't normally speak or write English. I often use this site to help me out.

Hello, I must carry out a program in My problem major is that I absolutely never made similar. The objective of my program is to recover certain present data in a file text, and then to trace a chart of these data. I work with Microsoft Visual Studio 2008.
the values are those located higher in my precedent post, I must thus save all the values recorded under Flr1 (38.9 ..... 39.0) and Flr2 (21.8….21.8) so on up to the Spg3 values the same scenario, and on the axis of the abcisses one will have the date and the time while on the y-axis will be to represent the temperatures (the values record under Flr1 ....... Spg3)
Thank you for your assistance and good day

Thx but that but my question still open

Do you have new question?

yes the last question on page 2,Topic:search and save von data in a textfile

Would you mind writing the question in words? So we can all understand what are you trying to do?

I must carry out a program in My problem major is that I absolutely never made similar. The objective of my program is to recover certain data present in a file text, and then to trace a chart of these data. I work with Microsoft Visual Studio 2008.
the values are those located higher in my precedent post, I must thus save all the values recorded under Flr1 (38.9 ..... 39.0) and Flr2 (21.8….21.8) so on up to the Spg3 values the same scenario, and on the axis of the abcisses one will have the date and the time while on the y-axis will be to represent the temperatures (the values record under Flr1 ....... Spg3)
Thank you for your assistance and good day

Zeitpunkt; Flr1; Flr2; Flr3; Flr4; Flr5; Flr6; Flr7; Flr8; Flr9; Flr10;Aus1;Aus2;Aus3;Aus4;Aus5;Aus6;Aus7;Aus8;Spg1;Spg2;Spg3;
10.05.2011 17:04:20; 38,9; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:30; 38,8; 21,8; 61,9; 10,4; 0,0; 24,7; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:40; 38,9; 21,8; 61,9; 10,5; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7;100; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:04:50; 38,8; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:00; 38,9; 21,8; 61,9; 10,4; 0,0; 24,6; 0,0; 0,0; -45,7; 8,6; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:10; 38,9; 21,9; 61,9; 10,5; 0,0; 24,7; 0,0; 0,0; -45,6; 8,7;100; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;
10.05.2011 17:05:20; 38,9; 21,8; 61,9; 10,5; 0,0; 24,6; 0,0; 0,0; -45,6; 8,7; 0; 0; 0; 0; 0; 0; 0;100; 0,00; 0,00; 0,00;

Hey, i am still looking for an answer,can somebody help me???

What have done so far?

I have try to convert binäre logfile in Byte Array,and Byte Array in Hexadecimal StringBuilder.it was good,but i have problem with the conversion of stringbuilder hexadecimal in integert value,may be can someone help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.