Example #1
0
        /// <summary>
        /// Browse button: Content of Blockget folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = Globals.BLOCKGET_FILE_FOLDER;
                openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;

                    //Read the contents of the file into a stream
                    var fileStream = openFileDialog.OpenFile();

                    using (StreamReader reader = new StreamReader(fileStream))
                    {
                        fileContent = reader.ReadToEnd();
                    }
                    textBoxFilePath.Text = filePath;
                    pictureBox1.Image    = WindowsThumbnailProvider.GetThumbnail(
                        textBoxFilePath.Text, pictureBox1.Width, pictureBox1.Height, ThumbnailOptions.None);
                }
            }
            //MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
        }
Example #2
0
 public void setImage(string filepath)
 {
     pictureBox1.Image = WindowsThumbnailProvider.GetThumbnail(
         filepath, pictureBox1.Width, pictureBox1.Height, ThumbnailOptions.None);
 }