Najdi a nahraď
C# .NET
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace najdi_a_nahrad
{
public partial class oknoProgramu : Form
{
public oknoProgramu()
{
InitializeComponent();
}
private void btnprochazetvychozi_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
txtvychozi.Text = openFileDialog.FileName;
}
private void btnzamen_Click(object sender, EventArgs e)
{
string najdi = txtnajdi.Text.ToLower();
string nahrad = txtnahrad.Text.ToLower();
string vychozijmeno = txtvychozi.Text;
string vyslednyjmeno = txtvysledny.Text;
List<string> data = new List<string>();
StreamReader vychozi = new StreamReader(vychozijmeno, Encoding.Default);
StreamWriter vysledny = new StreamWriter(vyslednyjmeno, false, Encoding.Default);
string radek;
while ((radek = vychozi.ReadLine()) != null)
{
data.Add(radek.ToLower());
}
foreach (string retezec in data)
{
if (retezec == najdi)
retezec.Replace(retezec, nahrad);
vysledny.WriteLine(retezec);
}
vychozi.Close();
vysledny.Close();
MessageBox.Show("Hotovo.");
}
private void btnprochazetvysledny_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
txtvysledny.Text = saveFileDialog.FileName;
}
}
}
Neformátovaný
Přidáno: 9.2.2017
Expirace: Neuvedeno