25/26jan2021. VEŽBE -> Upis teksta u fajl -> StreamWriter - Youtube snimci
Completion requirements
Prvi deo:
Programski kod:
using System;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string lokacija;
private void btnOtvori_Click(object sender, EventArgs e)
{
var ofd = new OpenFileDialog();
if(ofd.ShowDialog()==DialogResult.OK)
{
btnPisi.Enabled = true;
lokacija = ofd.FileName;
}
}
private void btnPisi_Click(object sender, EventArgs e)
{
try
{
using (var sw = new StreamWriter(File.Create(lokacija)))
{
sw.WriteLine(textBox1.Text);
sw.WriteLine(DateTime.Now);
sw.WriteLine("ovo je WriteLine");
sw.Write("ovo je prvi Write ");
sw.Write(" ovo je drugi Write");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
Drugi deo:
Last modified: Sunday, 31 January 2021, 11:41 PM