Example #1
0
        public Form1()
        {
            InitializeComponent();
            rectangle      = new Rectangle();
            parallelepiped = new Parallelepiped();
            var answer = MessageBox.Show("Do you want to open your data file ?", "Reader", MessageBoxButtons.YesNo);

            if (answer == DialogResult.Yes)
            {
                if (openDialog.ShowDialog() == DialogResult.OK)
                {
                    openDialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
                    path = openDialog.FileName;
                    using (FileStream fs = new FileStream(path, FileMode.Open))
                    {
                        using (BinaryReader stream = new BinaryReader(fs))
                        {
                            try
                            {
                                if (new FileInfo(path).Length != 0)
                                {
                                    foreach (char item in stream.ReadChars(500))
                                    {
                                        forSearchButton.Text += item;
                                    }
                                }
                            }
                            catch (EndOfStreamException ex)
                            {
                                forSearchButton.Text = "";
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                            finally
                            {
                                fs.Close();
                                stream.Close();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("You don't use cached data");
            }
        }
Example #2
0
 public Form1()
 {
     InitializeComponent();
     rectangle      = new Rectangle();
     parallelepiped = new Parallelepiped();
 }