Exemple #1
0
        private void AddFields(object sender, EventArgs e)
        {
            Fields     Field = new Fields();
            FileStream _FS   = new FileStream("Fields.txt", FileMode.Append);

            byte[] p; string Temp;

            Field.set_FieldID(Field_ID.Text);
            Field.set_FieldName(FieldName.Text);
            Field.set_ShelfNumber(ShelfNumber.Text);


            Field.Record_Len = Field.get_FieldID().Length + Field.get_FieldName().Length + Field.get_ShelfNumber().Length;

            _FS.WriteByte((byte)Field.Record_Len);

            //Write Field ID .
            _FS.WriteByte((byte)Field.get_FieldID().Length);
            Temp = Field.get_FieldID();
            p    = new byte[Field.get_FieldID().Length];
            for (int i = 0; i < Field.get_FieldID().Length; i++)
            {
                p[i] = (byte)Temp[i];
            }
            _FS.Write(p, 0, Field.get_FieldID().Length);

            //Write Field Name.
            _FS.WriteByte((byte)Field.get_FieldName().Length);
            Temp = Field.get_FieldName();
            p    = new byte[Field.get_FieldName().Length];
            for (int i = 0; i < Field.get_FieldName().Length; i++)
            {
                p[i] = (byte)Temp[i];
            }
            _FS.Write(p, 0, Field.get_FieldName().Length);

            //Write Shelf Number.
            _FS.WriteByte((byte)Field.get_ShelfNumber().Length);
            Temp = Field.get_ShelfNumber();
            p    = new byte[Field.get_ShelfNumber().Length];
            for (int i = 0; i < Field.get_ShelfNumber().Length; i++)
            {
                p[i] = (byte)Temp[i];
            }
            _FS.Write(p, 0, Field.get_ShelfNumber().Length);


            Field_ID.Clear();
            FieldName.Clear();
            ShelfNumber.Clear();

            _FS.Close();
        }