// Create a new file dialog
OpenFileDialog pOpenFileDialog = new new OpenFileDialog ();
// Setup dialog box title
pOpenFileDialog.Title = "open binary file";
// set to open a file type
pOpenFileDialog.Filter = "bin file (* *.) | * *. ";
// file exists monitor
pOpenFileDialog.CheckFileExists = true;
perform the following procedure after the file is opened //
iF (pOpenFileDialog.ShowDialog () == DialogResult.OK)
{
System.IO.Path.GetFullPath (pOpenFileDialog.FileName); // absolute path
System.IO.Path.GetExtension (pOpenFileDialog.FileName); // file extension
System.IO.Path.GetFileNameWithoutExtension (pOpenFileDialog.FileName); // file name without an extension
System.IO.Path.GetFileName (pOpenFileDialog.FileName); // get the file
System.IO.Path.GetDirectoryName (pOpenFileDialog.FileName); // get the path
}
FileStream inStream = new FileStream(pOpenFileDialog.FileName,FileMode.Open,FileAccess.Read);
long nBytesToRead = inStream.Length;
buffer = new byte[nBytesToRead];
int m=inStream.Read(buffer,0,buffer.Length);
inStream.Close();
// displayed richtextbox1 control and spaced with
richTextBox1.Clear();
for(int i=0;i<buffer.Length;i++)
{
richTextBox1.AppendText(buffer[i].ToString("X2")+" ");
}