Example #1
0
        //Read the relation between user pin and short message id(FileName:udata.dat)
        private void btnUDataRead_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int    iLength;
            int    iCount;

            int iPIN   = 0;
            int iSmsID = 0;

            lvUData.Items.Clear();
            openFileDialog1.Filter   = "udata(*.dat)|*.dat";
            openFileDialog1.FileName = "udata.dat";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(openFileDialog1.FileName);

                iLength = Convert.ToInt32(stream.Length);
                if (iLength % 4 != 0)
                {
                    MessageBox.Show("Data Error!", "Error", MessageBoxButtons.OK);
                    return;
                }
                iCount = iLength / 4;

                for (int j = 0; j < iCount; j++)
                {
                    byte[] byUDataInfo = new byte[4];
                    for (int i = 0; i < 4; i++)
                    {
                        byUDataInfo[i] = byDataBuf[j * 4 + i];
                    }
                    udisk.GetUDataFromDat(byUDataInfo, out iPIN, out iSmsID);

                    ListViewItem list = new ListViewItem();
                    list.Text = iPIN.ToString();
                    list.SubItems.Add(iSmsID.ToString());
                    lvUData.Items.Add(list);

                    byUDataInfo = null;
                }
                stream.Close();
            }
        }
Example #2
0
        //Read the relation between user pin and short message id(FileName:udata.dat)
        private void btnUDataRead_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            byte[] byDataBuf = null;
            int iLength;
            int iCount;

            int iPIN = 0;
            int iSmsID = 0;

            lvUData.Items.Clear();
            openFileDialog1.Filter = "udata(*.dat)|*.dat";
            openFileDialog1.FileName = "udata.dat";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
                byDataBuf = File.ReadAllBytes(openFileDialog1.FileName);

                iLength = Convert.ToInt32(stream.Length);
                if (iLength % 4 != 0)
                {
                    MessageBox.Show("Data Error!", "Error", MessageBoxButtons.OK);
                    return;
                }
                iCount = iLength / 4;

                for (int j = 0; j < iCount; j++)
                {
                    byte[] byUDataInfo = new byte[4];
                    for (int i = 0; i < 4; i++)
                    {
                        byUDataInfo[i] = byDataBuf[j * 4 + i];
                    }
                    udisk.GetUDataFromDat(byUDataInfo, out iPIN, out iSmsID);

                    ListViewItem list = new ListViewItem();
                    list.Text = iPIN.ToString();
                    list.SubItems.Add(iSmsID.ToString());
                    lvUData.Items.Add(list);

                    byUDataInfo = null;
                }
                stream.Close();
            }
        }