Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace WindowsFormsApp12
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         OpenFileDialog fisier = new OpenFileDialog( );
  17.         string line = "";
  18.  
  19.         OpenFileDialog imagine = new OpenFileDialog( );
  20.  
  21.         public Form1( )
  22.         {
  23.             InitializeComponent( );
  24.         }
  25.  
  26.         private void button1_Click( object sender, EventArgs e )
  27.         {
  28.             if (fisier.ShowDialog( ) == DialogResult.OK)
  29.             {
  30.                 StreamReader s1 = new StreamReader( fisier.FileName );
  31.                 while (line != null)
  32.                 {
  33.                     line = s1.ReadLine( );
  34.                     if (line != null)
  35.                     {
  36.                         listBox1.Items.Add( line );
  37.                     }
  38.                 }
  39.                 s1.Close( );
  40.             }
  41.         }
  42.  
  43.         private void button2_Click( object sender, EventArgs e )
  44.         {
  45.             if (imagine.ShowDialog( ) == DialogResult.OK)
  46.             {
  47.                 Image img = Image.FromFile( imagine.FileName );
  48.                 Bitmap btmap = new Bitmap( img, new Size(400, 250 ) );
  49.                 pictureBox1.Image = btmap;
  50.             }
  51.         }
  52.  
  53.         private void Form1_Load( object sender, EventArgs e )
  54.         {
  55.             fisier.Filter = "Text Files (.txt) | *.txt";
  56.             imagine.Filter = "Imagine | *.jpg; *.png; *.gif";
  57.         }
  58.  
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement