//To read the short messages in the Black&White screen devices (Filename:sms.dat) private void btnSMSRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength; int iCount;//count of short messages int iTag = 0; int iID = 0; int iValidMinutes = 0; int iReserved = 0; string sStartTime = ""; string sContent = ""; lvSMS.Items.Clear(); openFileDialog1.Filter = "sms(*.dat)|*.dat"; openFileDialog1.FileName = "sms.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 % 72 != 0) { MessageBox.Show("Data Error!", "Error", MessageBoxButtons.OK); return; } iCount = iLength / 72; for (int j = 0; j < iCount; j++)//loop { byte[] bySMSInfo = new byte[72]; for (int i = 0; i < 72; i++) { bySMSInfo[i] = byDataBuf[j * 72 + i]; } udisk.GetSMSFromDat(bySMSInfo, out iTag, out iID, out iValidMinutes, out iReserved, out sStartTime, out sContent); ListViewItem list = new ListViewItem(); list.Text = iTag.ToString(); list.SubItems.Add(iID.ToString()); list.SubItems.Add(iValidMinutes.ToString()); list.SubItems.Add(iReserved.ToString()); list.SubItems.Add(sStartTime); list.SubItems.Add(sContent); lvSMS.Items.Add(list); bySMSInfo = null; } stream.Close(); } }