I started learning C# a few days ago and I'm having a problem with public strings, I'm currently trying to write a program that copies and replaces files for practice but I'm having a problem with public strings no matter how much I try to change up the code I couldn't figure it out myself so I came here for help
What am I doing wrong?
Here's the code:
namespace Extractor
{
public partial class Form1 : Form
{
public string s
{
get;
set;
}
public string sSelectedPath
{
get;
set;
}
public string beckup
{
get;
set;
}
public Form1()
{
InitializeComponent();
}
private void direc_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.Description = "Select a folder";
if (fbd.ShowDialog() == DialogResult.OK)
{
string sSelectedPath = fbd.SelectedPath;
}
}
private void choof_Click(object sender, EventArgs e)
{
OpenFileDialog choofdlog = new OpenFileDialog();
choofdlog.Filter = "All Files (*.*)|*.*";
choofdlog.FilterIndex = 1;
choofdlog.Multiselect = true;
if (choofdlog.ShowDialog() == DialogResult.OK)
{
string s = choofdlog.FileName;
}
}
private void button3_Click(object sender, EventArgs e)
{
ReplaceFile( s, sSelectedPath, beckup);
}
public static void ReplaceFile(string FileToMoveAndDelete, string FileToReplace, string BackupOfFileToReplace)
{
File.Replace(FileToMoveAndDelete, FileToReplace, BackupOfFileToReplace, false);
}
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbb = new FolderBrowserDialog();
fbb.Description = "Select a folder";
if (fbb.ShowDialog() == DialogResult.OK)
{
string beckup = fbb.SelectedPath;
}
}
}