Last active
October 15, 2015 09:57
-
-
Save Michal-Szczepaniak/a177fd6ee04aad7c6551 to your computer and use it in GitHub Desktop.
Okienka z plikami
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bez openFileDialog | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Text; | |
using System.IO; | |
using System.Windows.Forms; | |
namespace WindowsApplication1 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void zapisz_Click(object sender, EventArgs e) | |
{ | |
StreamWriter writer = new StreamWriter("plik.txt"); | |
writer.Write(richTextBox1.Text); | |
writer.Flush(); | |
writer.Close(); | |
} | |
private void otworz_Click(object sender, EventArgs e) | |
{ | |
StreamReader reader = new StreamReader("plik.txt"); | |
richTextBox1.Text = reader.ReadToEnd(); | |
reader.Close(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Z openFileDialog | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Text; | |
using System.IO; | |
using System.Windows.Forms; | |
namespace WindowsApplication1 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void zapisz_Click(object sender, EventArgs e) | |
{ | |
saveFileDialog1.Filter = "Wszystkie pliki|*.*"; | |
saveFileDialog1.FileName = "plik.txt"; | |
if (saveFileDialog1.ShowDialog() == DialogResult.OK) | |
{ | |
StreamWriter writer = new StreamWriter(saveFileDialog1.FileName); | |
writer.Write(richTextBox1.Text); | |
writer.Close(); | |
} | |
} | |
private void otworz_Click(object sender, EventArgs e) | |
{ | |
openFileDialog1.Filter = "Wszystkie pliki|*.*"; | |
if (openFileDialog1.ShowDialog() == DialogResult.OK) | |
{ | |
StreamReader reader = new StreamReader(openFileDialog1.FileName); | |
richTextBox1.Text = reader.ReadToEnd(); | |
reader.Close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment