Advertisement
yugorin

Wyswietlanie tekstu

Dec 10th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 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.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace KickAss_Converter
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void textBox1_TextChanged(object sender, EventArgs e)
  22.         {
  23.  
  24.         }
  25.  
  26.         private void otworz_Click(object sender, EventArgs e)
  27.         {
  28.             Stream myStream = null;
  29.             OpenFileDialog openFileDialog1 = new OpenFileDialog();
  30.  
  31.             openFileDialog1.InitialDirectory = "c:\\";
  32.             openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
  33.             openFileDialog1.FilterIndex = 2;
  34.             openFileDialog1.RestoreDirectory = true;
  35.  
  36.             if (openFileDialog1.ShowDialog() == DialogResult.OK)
  37.             {
  38.                 try
  39.                 {
  40.                     if ((myStream = openFileDialog1.OpenFile()) != null)
  41.                     {
  42.                         using (myStream)
  43.                         {
  44.                             plikZrodlowy.Text = openFileDialog1.FileName;
  45.  
  46.                             string linie = File.ReadAllText(plikZrodlowy.Text);
  47.  
  48.                             // Display the file contents by using a foreach loop.
  49.                            // System.Console.WriteLine("Contents of WriteLines2.txt = ");
  50.                            // foreach (string  in linie)
  51.                            // {
  52.                                 // Use a tab to indent each line of the file.
  53.                                 // Console.WriteLine("\t" + line);
  54.                                 mojTekst.Text = linie;
  55.                            // }
  56.  
  57.                         }
  58.                         }  
  59.                    
  60.                 }
  61.                 catch (Exception ex)
  62.                 {
  63.                     MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement