Mitja Bonca 557 Nearly a Posting Maven

What would that look like?

Mitja Bonca 557 Nearly a Posting Maven

Code looks fine - it should work. I just dont know how do you create the timer. Create it like I do in the code, so it creats in the run time. This code of mine works:

public partial class Form1 : Form
    {
        Timer timer1;
        int counter;

        public Form1()
        {
            InitializeComponent();
            label1.Text = "countier: 0";
            CreatingTimer();
        }

        private void CreatingTimer()
        {
            timer1 = new Timer();
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Interval = 1000;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            counter++;
            timer1.Enabled = true;
            label1.Text = "counter: " + counter.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

You need to create an event on the form for press down. Look at this code:

public partial class Form1 : Form
    {        
        public Form1()
        {
            InitializeComponent();
            this.KeyDown += new KeyEventHandler(Form1_KeyDown);
        }

        private void buttonBegin_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Button \"Begin\" has been just pressed");
        }
        
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Alt && e.KeyCode == Keys.B)
            {
                buttonBegin_Click(null, null);
            }
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Take a look at this example I made for you:

public partial class Form1 : Form
    {
        delegate void MyDelegate(string msg);
        Timer timer1;
        int counter;

        public Form1()
        {
            InitializeComponent();
            label1.Text = "countier: 0";
            CreatingTimer();
        }

        private void CreatingTimer()
        {
            timer1 = new Timer();
            timer1.Tick+= new EventHandler(timer1_Tick);
            timer1.Interval = 1000;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            counter++;
            timer1.Enabled = true;
            UpdateLabel(counter.ToString());           
        }

        private void UpdateLabel(string value)
        {
            if (this.label1.InvokeRequired)
                this.label1.Invoke(new MyDelegate(UpdateLabel), new object[] { value });
            else
                label1.Text = "counter: " + value;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

You need to use delegate, which would check if the label needs invoke.

Mitja Bonca 557 Nearly a Posting Maven

tblAllEntries.Rows[0].Cells[3].Value = someThing.ToString(); //if the type of the column is not defined - by default is a type of string.

Mitja Bonca 557 Nearly a Posting Maven

I found the problem, You are closing the streamreader in each iteration. You should only close it after you are done, or if you use StreamReader implicitry (with keyword using), you better delete close() method (maxNum.Close() - delete it, you dont need it, implicit use of SR will close it automatically.

Mitja Bonca 557 Nearly a Posting Maven

You need to open streamReade before readint the stream.
But instead of opening, you can use the keyword "using", which will do all the needed code instead of you (open, close).

Put the StreamReader inthe the brackers of using, like this:

using(StreamReader sr = new StreamReader("filePath"))
{
    //you code for reading stream
}

Hope this helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Try this conversation:

DateTime dDate = DateTime.Now;
string sDate = dDate.ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB"); //dd/MM/yyyy
DateTime newDate = DateTime.Parse(sDate);
Mitja Bonca 557 Nearly a Posting Maven

If you still have problem (even if I gave you the example how this suppose to be done), you can send me your project to me. I will try to repair it, so it will work like it should.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This is how you can convert into both cases:

string ss2 = DateTime.Now.ToString("dd/MM/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);
 string ss3 = DateTime.Now.ToString("MM/dd/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);
Mitja Bonca 557 Nearly a Posting Maven

lol... think a bit . it wont hurt you. Use your brains, take a pen into your hand and write down some examples, how does it all has to go - openings forms, closing them ans so on.
YOu need to start using your own brains, we can do all the work instead of you - we can help you, but you are "requesting" from us to do all the job - where`s the point then?

If you dont want to use the pen and a paper to do some basic sketches, then you can think of what you need:
- Form1 is the MAIN form.
- Login is the additional form, but has to start before form1.
- Login windows HAS TO close by it self if the login is succeeded
- if Login is NOT correct login has to stay open and give a user another chance of inserting userName and pswd.
- Your login form can has a close button (the same as X button on the top right), which has to close the loginForm and Form1 (main form).
- for to logout, you need to create a list of yousers (you can usea generic List)
but it has to be on form1, or someplase else, BUT has nothing to do with login form.
- You can decide if the user has to enter his password to logout or not (to prevent that some one else will …

Mitja Bonca 557 Nearly a Posting Maven

What exactly is your Form2? A login?

if so you better use a ShowDialog method. This is an example:

using (Form2 form2 = new Form2())
                {
                    form2.StartPosition = FormStartPosition.CenterScreen;
                    if (form2.ShowDialog() == DialogResult.OK)
                    {
                        //if login is ok, form1 can start
                        Application.Run(new Form1());
                    }
                    //else, application will close or exit by it self.
                }
Mitja Bonca 557 Nearly a Posting Maven

or...
when you are showing form2, hide form1.
And when you want to go back to form1 from form2, close (or hide form2) and show form1.
As simple as that.

Mitja Bonca 557 Nearly a Posting Maven

This is how you bind objects:

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

        private void a()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            list.Add(new BindingObject(1, "One", null));
            list.Add(new BindingObject(2, "Two", null));
            list.Add(new BindingObject(3, "Three", null));
            dataGridView1.DataSource = list;
        }
    }

    public class BindingObject
    {
        private int intMember;
        private string stringMember;
        private string nullMember;
        public BindingObject(int i, string str1, string str2)
        {
            intMember = i;
            stringMember = str1;
            nullMember = str2;
        }
        public int IntMember
        {
            get { return intMember; }
        }
        public string StringMember
        {
            get { return stringMember; }
        }
        public string NullMember
        {
            get { return nullMember; }
        }
    } 
}
Mitja Bonca 557 Nearly a Posting Maven

That has to be a remote db. So everyone can access it. Some info.

Mitja Bonca 557 Nearly a Posting Maven

This is my code (I actually use it as well):

public static bool LogingInMethod(string userName, string password)
        {
            bool result = false;

            string sqlQuery = "SELECT UserName, Password FROM Users WHERE UserName ='" + userName + "'";
            using (SqlConnection sqlConn = new SqlConnection(p))
            {
                SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn);
                SqlDataReader reader;
                bool HasRows = false;
                try
                {
                    sqlConn.Open();
                    reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())

                            if (password == reader["Password"].ToString().Trim())
                            {
                                result = true;
                                break;
                            }
                        HasRows = true;
                    }
                    reader.Close();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    sqlConn.Close();
                }
                finally
                {
                    if (sqlConn.State == ConnectionState.Open)
                    {
                        sqlConn.Close();
                    }
                    cmd = null;
                    reader = null;
                    GC.Collect();
                }

                if (result == true)
                {
                    result = true;
                }

                else if (HasRows == false)
                {
                    MessageBox.Show("Wrong userName.", "Eror", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
                else
                {
                    MessageBox.Show("Wrong password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
            }
            return result;
        }
Mitja Bonca 557 Nearly a Posting Maven

Singlem has given you the code you want. His code starts the timer in the constructor and after 10 seconds the timer Tick event rises and opens form2 - exactly as you wanted. Correct? Or do you want to start the timer? If so put the code of the timer (which is not in constructor of the class) into some button event. And will do.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

One of the things that classes can do is inheritances (structs cannot).
There is plenty of specifications, but you better read it by your self (and learn it):

STRUCT: http://msdn.microsoft.com/en-us/library/saxz13w4.aspx
CLASS: http://msdn.microsoft.com/en-us/library/x9afc042.aspx

Mitja Bonca 557 Nearly a Posting Maven

You can use an even FormClosing. Create this event on form creation, and when you will try to exit form, the event formClosing will be rised:

public Form1()
        {
            InitializeComponent();
            this.FormClosing+=new FormClosingEventHandler(Form1_FormClosing);
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //here you do the code!
        }

btw, for which control do you use delegate for invoke it? If you wont salve the problem, please feel free to paste some of the code in here - so I can be in a bigger help.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

you 1st go to the html code of that form and then
see carefully that there should be one and only one from tag after body tag.
and it should be closed before that body tag
like this
<body>
<form ......>
</form>
</body>

Mitja Bonca 557 Nearly a Posting Maven

If I understand it is like this:
- you open form1
- then you would like to close form1, and open form2?

or:
- open form1
- open form2
- then close form2, and open form3

This is a bit difference, becuase you have started app. with form1 ( Application.Run(new Form1());)

Mitja Bonca 557 Nearly a Posting Maven

We are talking about structs now and your example, this is what you are asking:

SPoint sPoint1 = new SPoint();
 sPoint1.X = 999;
 SPoint sPoint2 = sPoint1;
Mitja Bonca 557 Nearly a Posting Maven

You did a mistake in your last statement, I thnik you had this in mind: "adding to a CLASS variable makes it a mistake".

Answer: (read my post carefully ones again from the beginning). Its because your variable "cPoints" it is only a reference to a class.


You have to do it like this:

namespace Jan11Struct
{
    class Program
    {
        static void Main(string[] args)
        {
            CPoint[] cPoints = new CPoint[10];
            SPoint[] sPoints = new SPoint[10];

            //cPoints[7].X = 20; //runtime error
            cPoints[7] = new CPoint(20);
            sPoints[7].X = 20;
            Console.WriteLine("Class value: {0} .... Struct value: {1}.", cPoints[7], sPoints[7].X);
            Console.ReadLine();
        }
    }
}

class CPoint
{
    public int X;
    public CPoint(int _X)
    {
        this.X = _X;
    }
}
struct SPoint
{
    public int X;
}

Hope this helps explaning the difference between the class and the struct.
Mitja

NewOrder commented: Now i understand +0
Mitja Bonca 557 Nearly a Posting Maven

A class is a reference type. When an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.

In general, classes are used to model more complex behavior, or data that is intended to be modified after a class object is created. Structs are best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.

Mitja Bonca 557 Nearly a Posting Maven

Try and let me know, but remember, when working wit dgv control, best "tool" for populating it, is a dataTable. A good example you have here.

vedro-compota commented: ++++++ +1
Mitja Bonca 557 Nearly a Posting Maven

Which array exactly? Or string[], ArrayList, generic List ?
And how many columns has your dgv?

Just for your info, for populating dgv, its best practice to use DataSet (or DataTable). Its specially designed for that, becuase you can create columns and rows, its actually a copy of dgv. In arrays you CANNOT have any columns, so populating its hard - or better said - useless.

vedro-compota commented: +++++++++ +1
Mitja Bonca 557 Nearly a Posting Maven

When ever you are not sure how long is gonna be the array, you never use a "basic" arrays like: string[], int[], bool[], or what ever of these kind.
ddanbe has perfectly right, use a generic list, which is in my opinion my far the best type of array. If offers so many posiblilities to work with.

or you can even use an ListArray - for this you have to create a new namespace (System.IO)

Mitja

Mitja Bonca 557 Nearly a Posting Maven

The code above will never work, for many reasons:
1. as ddanbe said, C# needs Main() method to get started (so no Go() method - change the name to Main)
2. About _gameDirectory = FindGameDirectory() ? Where did you innisiate it? Its from no where now.
You cannot call in instance from outside of the static method, so you have to create a new one in the static Main method - where it all begins.
3. Whats this method: AddAsmToRootPatchFile(); ? Is it a static or now? If its not, it wont compile.

this for beginning
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Please take both examples, in the upper post and this one in here.
The same example would be with using keyword "out":

static void Main(string[] args)
        {
            int value = 2;
            List<string> list;
            CreateList(out list, value);

            for (int i = 0; i < list.Count; i++)
                Console.WriteLine("{0}", list[i]);
            Console.ReadLine();
        }

        private static void CreateList(out List<string> list, int howMany) 
        {
            list = new List<string>();
            for (int i = 0; i < howMany; i++)
            {
                string sItem;
                Calculate(out sItem, i);
                list.Add(sItem);
            }
        }

        private static void Calculate(out string item, int i)
        {
            switch (i)
            {
                case 0:
                    {
                        item = "one";
                        break;
                    }
                case 1:
                    {
                        item = "two";
                        break;
                    }
                case 2:
                    {
                        item = "three";
                        break;
                    }
                default:
                    {
                        item = "none";
                        break;
                    }
            }
        }
NewOrder commented: Thank you +0
Mitja Bonca 557 Nearly a Posting Maven

Using of out method parameter its good too. You can use it if you want in your example, but its pointless to pass the parameter into the method, that will be returned as well. Mostly you pass parameters that you need in methods, and return those that you need in the previous method, like a simple example:

static void Main(string[] args)
        {
            int value = 2;
            List<string> list = CreateList(value);

            for (int i = 0; i < list.Count; i++)
                Console.WriteLine("{0}", list[i]);
            Console.ReadLine();
        }

        private static List<string> CreateList(int howMany)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < howMany; i++)
            {
                string sItem = Calculate(i);
                list.Add(sItem);
            }
            return list;
        }

        private static string Calculate(int i)
        {
            string item = null;
            switch (i)
            {
                case 0:
                    {
                        item = "one";
                        break;
                    }
                case 1:
                    {
                        item = "two";
                        break;
                    }
                case 2:
                    {
                        item = "three";
                        break;
                    }
                default:
                    {
                        item = "none";
                        break;
                    }
            }
            return item;
        }

I hope you get the point. SUM: you don`t need to pass the parameter into the method from which will be the same returned. Actually you can, but this is not the proper way if you get me. But if you want you still can do it, and use out method parameter.
Just that!

Mitja Bonca 557 Nearly a Posting Maven

Becuase you are using static methods, you can only use the objects inisde of them, and whats is passed from one to another. This is what you can do:

class MyClass
{   
    public static void Main(string[] args)
    {        
       Pieces[,] = ChessBoard();
    }

    public static Pieces[,] ChessBoard( )
    {
        Pieces [,] pieces = new Pieces[9,9];
        //code to fill the pieces (which you have alreay)
  
        return pieces;
    }
}

This will do it.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This can help you out:
1. the currency depending on the culture,
2. the currency in your wanted format without any cash mark

int iValue = 2879068;
string sValue1 = String.Format("{0:C}", iValue);
string sValue2 = String.Format("{0:#,#.}", iValue);

but in case if you want to have some cash mark, simply do:

{0:$#,#.}//or
{0:#,#.€}

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

How will you choose 3,5 or 7 option? You have to do an option to let the user chooses it, and then its simple - get the number user has choosen, and pass it to the method which will create the field of buttons to play:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jan08Exercise
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.comboBox1.Items.AddRange(new string[] { "3x3", "5x5", "7x7" });
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string item = comboBox1.GetItemText(comboBox1.SelectedItem);
            if (item != String.Empty)
            {
                string sNumber = item.Substring(0, item.Length - 2);
                int value = Convert.ToInt32(sNumber);
                CreatingField(value);
            }
        }

        private void CreatingField(int value)
        {
            for (int x = 0; x < value; x++)//loop relating to rows
            {
                for (int y = 0; y < value; y++)//loop relating to columns
                {
                    nandcButton[x, y] = new Button();//Create the Buttons
                    nandcButton[x, y].Name = "nandcButton" + x + "," + y;//name and coordinates and set up number, number to show
                    nandcButton[x, y].Width = 60;
                    nandcButton[x, y].Height = 60;
                    nandcButton[x, y].Left = nandcButton[x, y].Left + nandcButton[x, y].Width + (x * 60);
                    nandcButton[x, y].Top = nandcButton[x, y].Top + nandcButton[x, y].Top + 50 + (y * 60); //Centre the button 
                    nandcButton[x, y].Click += new EventHandler(Button_Click); //links the above button spec.
                    //Add them to the container
                    nandcHolder.Controls.Add(nandcButton[x, y]);
                    nandcButton[x, y].Text = " "; //declares text
                }
            }
        }
    }
}

Hope it helps a bit.
If this is not something you wanted, …
Mitja Bonca 557 Nearly a Posting Maven

Maybe this will do? :

string filename = "f:\\date.txt";
            using (StreamReader stream = new StreamReader(filename))
            { 
                string line;
                while ((line = stream.ReadLine()) != null)
                {
                    string[] array = line.Split(' ');
                    int a = Convert.ToInt32(array[0]); //1.
                    string b = array[1];               //2.
                    string c = array[2];               //3.
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

Is the string seperated by something? By whitespaces maybe?

Mitja Bonca 557 Nearly a Posting Maven

I dont find anything that can be connected with if,else loops in your code, ok it could be, but it would be too complicated.
In my opinion fawi`s approach is the right one, I will only modify it a bit, to suit your needs:

bool flag = false;
            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if (nandcButton[i, j] == "0")
                        flag = true;
                }
            }
            if (flag == true)
            {
                //the requirment has been fulfiled!
            }

Hope this helps,
Mitja

johnt68 commented: Thanks for the help +1
Mitja Bonca 557 Nearly a Posting Maven

This is what I meant:

// read CSV file
        private DataTable BuildDataTable(string fileFullPath, char seperator)
        {
            StreamReader myReader; //put a new instance of StreamReader here, so it will be accessable in whole method
            const int EOF = -1;

            DataTable myTable = new DataTable("MyTable");
            DataRow myRow;
            try
            {
                myReader = new StreamReader(fileFullPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error opening streamreader: " + ex.Message);
                return new DataTable("Empty");
            }
            try
            // Open file and read first line to determine how many fields there are.
            {
                string[] fieldValues = myReader.ReadLine().Split(new Char[] { seperator, ';' });
                // Adding the first line of data to data table (columnnames?
                // Create data columns accordingly
                for (int i = 0; i < fieldValues.Length; i++)
                {
                    myTable.Columns.Add(new DataColumn(fieldValues[i].ToString().Trim()));
                }
                //Now reading the rest of the data to data table
                while (myReader.Peek() != EOF)
                {
                    fieldValues = myReader.ReadLine().Split(new Char[] { seperator });
                    myRow = myTable.NewRow();
                    for (int i = 0; i < fieldValues.Length; i++)
                    {
                        myRow[i] = fieldValues[i].ToString().Trim();
                    }
                    myTable.Rows.Add(myRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error building datatable: " + ex.Message);
                return new DataTable("Empty");
            }
            finally
            {
                if (myReader != null)
                {
                    myReader.Close();
                }
            }
            myTable.AcceptChanges();
            return myTable;
        }

If this is not it, please let me know.
What bothers me, are those 2 chatch bloces. Do you have any issues with them? If not, its ok.

ddanbe commented: For the effort! +8
Mitja Bonca 557 Nearly a Posting Maven

Why dont you put a StreamReader object out of any loops, so it can be accessible to any other sub brackets, loop, etc, like:

StreamReader myReder;
            DataTable myTable = new DataTable("MyTable");
            DataRow myRow;
            try
            {
               myReader = new StreamReader(fileFullPath);
            }

            //code continues..
Mitja Bonca 557 Nearly a Posting Maven

This can be some kind of a leading way for you. There is plenty of way how to implement your issue, but one of my best and very efficient is to use while loop.
While some value (usually is a boolean) is not the contrary of the pre-set one, the loop is going on to infinity, until some goal is not reached. In your case this goal is when the user enters something (what ever you want).
You can even put some code for validating age, tel.numbers, and stuff like that - I actaully did an example for checking the integer - users age (but if you would like to know more, please start a new thread).

This is your code:

class Program
    {
        static void Main(string[] args)
        {
            bool bDataOK = false;
            string value = null;

            Console.WriteLine("Please write your name:"); 
            while (!bDataOK)
            {                
                value = Console.ReadLine();
                if (value != String.Empty)
                    bDataOK = true;       
                if(!bDataOK)
                    Console.WriteLine("You forgot to enter you name...");  
            }

            //now when the user has entered his bame, we can continue with the code:
            Console.WriteLine("Please enter your age:");
            bDataOK = false;
            while (!bDataOK)
            {                
                value = Console.ReadLine();
                if (value != String.Empty)
                {
                    //now checking for the age (if user really entered an integer:
                    bDataOK = CheckingAge(value);
                    if (bDataOK)
                        bDataOK = true;
                }
                if(!bDataOK)
                    Console.WriteLine("You forgot to enter you age...");  
            }
        }

        private static bool CheckingAge(string sAge)
        {
            int iAge = 0;
            bool bChecking = int.TryParse(sAge, out iAge);
            if (bChecking)
                return true;
            else
                return false; …
Mitja Bonca 557 Nearly a Posting Maven

What are you trying to get with using Read() method?
This method returns an integer (not a string) so that it can return -1 if the end of the stream has been reached (like you did in your example), but I still dont get what are you trying to get - if you want to get the string inside the file, it will simply not go.
This why you have to use ReadLine(), or method like adapost has shown you in post above.

I hope this helps clearing the issue here.
best regards,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

I have chnaged a code a bit, and now it works:

private void ReadingFile()
        {
            using (StreamReader sr = new StreamReader(@"C:\1\map.txt"))
            {
                string line;
                // Read and display lines from the file until the end of 
                // the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    if (line != String.Empty)
                        label1.Text = line + Environment.NewLine;
                }
            }
        }

I hope it does work for you too.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Would you mind giving me the content of the file? So I can try it on my own.

btw, where you read: Voronezh 20 20 2 4 5

Mitja Bonca 557 Nearly a Posting Maven

Where it hangs up? Or is it tryig to go into infinity in the while loop? If so, that means its still reading the file - mayne you read a file byte by byte (like I showed you on the previous example) and this is taking very long time - depends of the file lenght.
Otherwise I cannot see any other reason to hang up.
Take a look in a debug mode (put the break point and go line by line with pressing F11).

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

hmm... Did you save the data into a file in the same order then you are retreiving them back out?

the point is that you cannot just simply asign some binary data to something. You have to get the data into the text in some order, and then retreive them back in the same way:EXAMPLE!

If this is not enough its better to take a look into some other example, that you will learn how to use bytes and converted them back to the characters (strings, integers,...).

Give it some time and go through all the code slowely:
http://msdn.microsoft.com/es-es/library/system.io.binaryreader.aspx

Mitja Bonca 557 Nearly a Posting Maven

Not in english? So this is useless then.
But there is the code you wanted - to read character by character:

using (StreamReader sr = new StreamReader(path)) 
            {
                //This is an arbitrary size for this example.
                char[] c = null;

                while (sr.Peek() >= 0) 
                {
                    c = new char[1]; //1 character at a time
                    sr.Read(c, 0, c.Length);
                    //The output will look odd, because
                    //only five characters are read at a time.
                    Console.WriteLine(c);
                }
            }

Hope it does some help to you.

Mitja Bonca 557 Nearly a Posting Maven

btw, why do you use a BinaryRader class, becuase you only read from a text file?
Why you dont use StreamReader instead, and you wont even need to convert byte into string, something?

An idea.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

What exactly do you mean?
Here is some info about using commands:
http://www.daniweb.com/code/snippet303280.html

Mitja Bonca 557 Nearly a Posting Maven

You can do it like that:

using (StreamReader reader = new StreamReader(@"C:\myFile.txt"))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                label1.Text += line + Environment.NewLine;
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

Why do you want to encode a text? A text its alredy encoded, dont you think. You only need to get it from the file into a label.

vedro-compota commented: +++++ +1